[MODULES-6687] inifile no longer manages existing lines in puppet post 5.4.0 Created: 2018/02/23  Updated: 2018/06/18  Resolved: 2018/06/18

Status: Resolved
Project: Modules
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Normal
Reporter: Past Haus Assignee: Eric Putnam
Resolution: Fixed Votes: 0
Labels: customer0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Blocks
Relates
relates to PUP-8442 type parameters do not honor when def... Ready for Engineering
relates to MODULES-6825 puppet_agent 1.6.0 Closed
relates to MODULES-6723 Supported Release (inifile) 2.2.1 - (... Resolved
Template: MODULES Bug Template
Method Found: Needs Assessment
QA Risk Assessment: Needs Assessment

 Description   

.comm*Puppet Version: f77e9e00efcf9bd8dac66c6622f35cbe16c8eb7a (5.5.0)*
Puppet Server Version: (5.2.0)
OS Name/Version: Rhel 7

Describe your issue in as much detail as possible…
Describe steps to reproduce…

Desired Behavior:
Even when using a codedir with only the inifile module installed, it should work.

In this example, /tmp/configure_inifile.aPkO3n is a tmpdir with just the inifile module installed.

An inifile resource such as the following should modify the existing java_args line:
 

[root@b3wa4ws5mg41efr ~]# puppet apply --codedir /tmp/configure_inifile.aPkO3n -e 'ini_setting { "JAVA_ARGS":
 ensure => present,
 path => "/etc/sysconfig/puppetserver",
 section => "",
 setting => "JAVA_ARGS",
 key_val_separator => "=",
 value => "\"-Xmx2g -Xms2g -XX:+PrintTenuringDistribution -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:/var/log/puppetlabs/puppetserver/gc.log\"",
}'

In this case the value of JAVA_ARGS in the file is JAVA_ARGS="-Xms2g -Xmx2g -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger"

Actual Behavior:

It does not. inifile seems to be able to remove lines and add lines that don't already exist, but modifying existing lines does not work. Unfortunately even with --trace, --verbose and --debug there isn't anything useful coming out of the module. Note: this seems to only be the case when inifile is installed in its own codedir and puppet apply --codedir $codedir is used. When inifile is present in /etc/puppetlabs/code/environments/production/modules/inifile with other modules the resource behaves as expected.



 Comments   
Comment by Past Haus [ 2018/02/23 ]

Minimal reproducer:

  1. Make a tmpdir ($tmpdir)
  2. Install inifile module to $tmpdir puppet module install puppetlabs-inifile --codedir $tmpdir
  3. Make a file with SETTING="foo" in it (call it temp-file)
  4. Make the following puppet manifest (call it test-resource.pp):

    ini_setting { "JAVA_ARGS":
       ensure                => present,
        path                 => "/path/to/temp-file",
         section             => "",
          setting            => "SETTING",
           key_val_separator => "=",
            value            => "BAR",
    }

  5. Run the following puppet code puppet apply --codedir $tmpdir test-resource.pp
  6. Watch nothing happen when it should (then try it with 5.4.0 and watch it work)
Comment by Past Haus [ 2018/02/23 ]

A bisect showed this commit as the culprit:
https://github.com/puppetlabs/puppet/commit/c98bb6787fa2ec04842a92924dd4eb8e41bddd78

Also I can't explain why having multiple modules in codedir made the problem go away but having only the one module in codedir doesn't work.

Comment by Past Haus [ 2018/02/23 ]

These are the modules where it seems to work with:

accounts  apache  archive  chocolatey         concat  dotnet         epel      gitlab   graphite_powershell  hiera  iis       inifile  java_ks  logstash           memcached  ntp       pe_metric_curl_cron_jobs  powershell        reboot  registry  sensu    stdlib  vcsrepo             windows_env       windowsfeature    wsus_client
acl       apt     aws      chocolatey_server  docker  elasticsearch  firewall  grafana  haproxy              hocon  influxdb  java     jenkins  logstashforwarder  nginx      openldap  postgresql                puppetserver_gem  redis   rsyslog   staging  tomcat  windows_autoupdate  windows_eventlog  windows_firewall  yum

Comment by Jacob Helwig [ 2018/02/26 ]

This looks like it's actually a problem with the inifile module itself. If you set "refreshonly => false" in the manifest for the resource, we get the exact same behavior with or without c98bb6787f. insync? in the type should be checking if :refreshonly is present, and that it's not the symbol :false. The issue c98bb6787f introduced is that now both the default false value, and an explicit false value cause :refreshonly to be present as the symbol :false instead of just an explicit false value.

Comment by Past Haus [ 2018/02/26 ]

(Refreshonly was added in https://github.com/puppetlabs/puppetlabs-inifile/commit/ede74d1a6717045c3e41e966c975e6853c1a8d6b#diff-51e85e609868723d3a218491f57c929c)

Comment by Eric Putnam [ 2018/02/26 ]

https://github.com/puppetlabs/puppetlabs-inifile/pull/268

Comment by Daniel Parks [ 2018/03/02 ]

Adding customer0 label since this is affecting our internal infrastructure in production.

Comment by Josh Cooper [ 2018/03/02 ]

We probably want to do the following instead so that puppet always coerces the values to boolean false or true, but never nil, :false, etc.

  newparam(:refreshonly, boolean: true, parent: Puppet::Parameter::Boolean) do
    desc '...'
    defaultto false
  end

Then things like @resource[:refreshonly} will work as expected.

Comment by Eric Putnam [ 2018/03/02 ]

Josh Cooper https://github.com/puppetlabs/puppetlabs-inifile/pull/269

Generated at Sat Sep 19 12:20:01 PDT 2020 using Jira 8.5.2#805002-sha1:a66f9354b9e12ac788984e5d84669c903a370049.