-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nitish add force parameter to create new section #286
Nitish add force parameter to create new section #286
Conversation
1) Added the has_section to the ini_file class in util folder 2) Converted to nested if 3) Removed reduntant paranthesis around method calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Could you describe the purpose of this new parameter in your commit message or PR description.
- Rubocop is failing on a few things. You can find these in the GitHub CI output
- The new parameter will need a readme entry before merging.
lib/puppet/type/ini_setting.rb
Outdated
| @@ -39,6 +39,11 @@ def munge_boolean_md5(value) | |||
| end | |||
| end | |||
|
|
|||
| newparam(:force_new_section_creation, :boolean => true, :parent => Puppet::Parameter::Boolean) do | |||
| desc 'Create setting only if the section exists' | |||
| defaultto(true) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaulting to true seems like the opposite behavior of what currently exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current behavior is that it creates the section and the setting if it does not exist in the ini file. So defaulting force_new_section_creation to True will also create the new section.
| resource[:ensure] = :absent | ||
| resource[:force_new_section_creation] | ||
| else | ||
| !resource[:force_new_section_creation] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be idempotent? It seems like it would be trying to call create every puppet run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried different combinations of setting and it does not call create on every puppet run
1) White spaces were removed 2) renamed functions that return boolean value to appropriate name
The intent here is to manage the multiple redhat.repo config files on different servers. The files cannot be managed by Puppet as these will be generated by Satellite dynamically. The current behavior of the module creates new section and setting if it does not exist in the .ini file. What we want to achieve is that the module should not create new section in the .ini file if it does not exist. So we created a new param force_new_section_creation which is set to True by default, so that it doesn't break the previous logic. If it is set to False then it will not create the new section in the .ini file even if it is set to present.
|
|
@hunner are you happy enough with the changes? |
|
@hunner ??? |
|
merging, @hsitin - you might want to add some tests around the new behaviour though :) |
|
@davidmalloncares @hsitin we're seeing failures with this change, 2018-06-22 14:59:50 | 2018-06-22 14:59:50,545 INFO: �[1;31mError: /Stage[main]/Glance::Backend::Swift/Glance_swift_config[ref1/user]: Could not evaluate: Invalid parameter force_new_section_creation(:force_new_section_creation)�[0m Still investigating |
[1] is breaking TripleO deployments, see https://bugs.launchpad.net/tripleo/+bug/1778247 [2] - puppetlabs/puppetlabs-inifile#286 Change-Id: I241fb6245ee31aff71c1fb405c883f151d8c3dcf
| !ini_file.get_value(section, setting).nil? | ||
| if ini_file.section?(section) | ||
| !ini_file.get_value(section, setting).nil? | ||
| elsif !resource[:force_new_section_creation] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the issue i'm seeing is with this. If you're child object doesn't have this parameter (none of ours do because we're not inheriting from the upstream ini_setting type) this fails. I think what we need to do is check that this option is a value on the type before trying to consume it.
|
A proposed fix is available at #288 @hsitin and @davidmalloncares please review |
…ter_to_create_new_section Nitish add force parameter to create new section
No description provided.