Issue #12604 has been reported by Zach Leslie.

----------------------------------------
Bug #12604: File audit fails under certain conditions the first time of a 
puppet run, but not after.
https://projects.puppetlabs.com/issues/12604

Author: Zach Leslie
Status: Unreviewed
Priority: High
Assignee: 
Category: 
Target version: 
Affected Puppet version: 
Keywords: 
Branch: 


# The Problem

Puppet throws an error when auditing file resources with a source paramater 
under certain conditions.

# The Environment

The testes were run within the following environment.

<pre>
[install]
  # Puppet install environment for non permanent monitoring 
  manifest = $confdir/environments/install/manifests/site.pp
  modulepath = 
$confdir/environments/install/modules:/opt/puppet/share/puppet/modules
</pre>

The site.pp contains the following code.
<pre>
node default { 
  class { 'dummy': } 
}

class dummy () inherits dummy::params {

  sysconfig::deploy { "${module_label}_dummy": 
    module       => $module_label, 
    path         => '/tmp', 
    file         => 'dummy', 
    #sourceselect => first, 
    #recurse      => false, 
    owner        => 'root', 
    group        => 'root', 
    mode         => '0755', 
    setaudit     => true; 
    }

}

class dummy::params { 
  $module_label = 'dummy' 
}

define sysconfig::deploy ($module,$path,$file,$owner,$group,$mode,$setaudit){

  file { "${path}/${file}": 
    ensure       => $ensure, 
    source       => [ 
      "puppet:///modules/foo/one", 
      "puppet:///modules/foo/two", 
      "puppet:///modules/foo/three", 
    ], 
    #content      => "foo",
    replace      => $replace, 
    sourceselect => $sourceselect, 
    recurse      => $recurse, 
    force        => $force, 
    owner        => $owner, 
    group        => $group, 
    mode         => $mode, 
  }

  if $setaudit == true { 
    File["${path}/${file}"] {
      audit => [ 'owner','group','mode'], 
    }
  }
}
</pre>


# Making things break

1. To reproduce, ensure that `/tmp/dummy` is nonexistent.

<pre>
# ls -ld /tmp/dummy
ls: cannot access /tmp/dummy: No such file or directory
</pre>

2. Run puppet agent agains the environment.
<pre>
# puppet agent -t --environment install --noop
info: Retrieving plugin
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Caching catalog for pe-centos6.localdomain
info: Applying configuration version '1320849952'
notice: 
/Stage[main]/Dummy/Sysconfig::Deploy[dummy_dummy]/File[/tmp/dummy]/ensure: 
current_value absent, should be file (noop)
notice: Sysconfig::Deploy[dummy_dummy]: Would have triggered 'refresh' from 1 
events
notice: Class[Dummy]: Would have triggered 'refresh' from 1 events
notice: Stage[main]: Would have triggered 'refresh' from 1 events
notice: Finished catalog run in 1.89 seconds
</pre>

3. Create the file, but not with puppet. 
<pre>
root@pe-centos6:/etc/puppetlabs/puppet/environments/install
# touch /tmp/dummy                            
</pre>

4. Run the puppet agent against the environment again.
<pre>
root@pe-centos6:/etc/puppetlabs/puppet/environments/install
# puppet agent -t --environment install --noop
info: Retrieving plugin
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Caching catalog for pe-centos6.localdomain
info: Applying configuration version '1320849952'
notice: 
/Stage[main]/Dummy/Sysconfig::Deploy[dummy_dummy]/File[/tmp/dummy]/content: 
--- /tmp/dummy  2011-11-09 06:46:02.985917971 -0800
+++ /tmp/puppet-file20111109-10363-nsw732-0     2011-11-09 06:46:10.278952999 
-0800
@@ -0,0 +1 @@
+one

notice: 
/Stage[main]/Dummy/Sysconfig::Deploy[dummy_dummy]/File[/tmp/dummy]/content: 
current_value {md5}d41d8cd98f00b204e9800998ecf8427e, should be 
{md5}5bbf5a52328e7439ae6e719dfe712200 (noop)
err: /Stage[main]/Dummy/Sysconfig::Deploy[dummy_dummy]/File[/tmp/dummy]: Could 
not evaluate: undefined method `send_log' for nil:NilClass
notice: Finished catalog run in 2.85 seconds
</pre>

5. Note the failure here is `undefined method 'send_log'`.  If we run the agent 
again, this error does not exist.
<pre>
# puppet agent -t --environment install --noop
info: Retrieving plugin
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Caching catalog for pe-centos6.localdomain
info: Applying configuration version '1320850100'
notice: 
/Stage[main]/Dummy/Sysconfig::Deploy[dummy_dummy]/File[/tmp/dummy]/content: 
--- /tmp/dummy  2011-11-09 06:46:02.985917971 -0800
+++ /tmp/puppet-file20111109-10638-sfdv5g-0     2011-11-09 06:48:24.293243167 
-0800
@@ -0,0 +1 @@
+one

notice: 
/Stage[main]/Dummy/Sysconfig::Deploy[dummy_dummy]/File[/tmp/dummy]/content: 
current_value {md5}d41d8cd98f00b204e9800998ecf8427e, should be 
{md5}5bbf5a52328e7439ae6e719dfe712200 (noop)
notice: 
/Stage[main]/Dummy/Sysconfig::Deploy[dummy_dummy]/File[/tmp/dummy]/mode: 
current_value 0644, should be 0755 (noop)
notice: Sysconfig::Deploy[dummy_dummy]: Would have triggered 'refresh' from 2 
events
notice: Class[Dummy]: Would have triggered 'refresh' from 1 events
notice: Stage[main]: Would have triggered 'refresh' from 1 events
notice: Finished catalog run in 2.10 seconds
</pre>

6. If we now remove `/tmp/dummy` and run the agent yet again we get a different 
method the first time, but subsequent runs complete without error.
<pre>
root@pe-centos6:/etc/puppetlabs/puppet/environments/install
# rm /tmp/dummy
root@pe-centos6:/etc/puppetlabs/puppet/environments/install
# puppet agent -t --environment install --noop
info: Retrieving plugin
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Caching catalog for pe-centos6.localdomain
info: Applying configuration version '1320850268'
notice: 
/Stage[main]/Dummy/Sysconfig::Deploy[dummy_dummy]/File[/tmp/dummy]/ensure: 
current_value absent, should be file (noop)
notice: 
/Stage[main]/Dummy/Sysconfig::Deploy[dummy_dummy]/File[/tmp/dummy]/owner: audit 
change: previously recorded value root has been changed to absent
notice: 
/Stage[main]/Dummy/Sysconfig::Deploy[dummy_dummy]/File[/tmp/dummy]/group: audit 
change: previously recorded value root has been changed to absent
err: /Stage[main]/Dummy/Sysconfig::Deploy[dummy_dummy]/File[/tmp/dummy]: Could 
not evaluate: undefined method `rjust' for :absent:Symbol
notice: Finished catalog run in 1.77 seconds
[1]    11162 exit 4     puppet agent -t --environment install --noop
root@pe-centos6:/etc/puppetlabs/puppet/environments/install exited 4
# puppet agent -t --environment install --noop
info: Retrieving plugin
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Loading facts in facter_dot_d
info: Caching catalog for pe-centos6.localdomain
info: Applying configuration version '1320850268'
notice: 
/Stage[main]/Dummy/Sysconfig::Deploy[dummy_dummy]/File[/tmp/dummy]/ensure: 
current_value absent, should be file (noop)
notice: Sysconfig::Deploy[dummy_dummy]: Would have triggered 'refresh' from 1 
events
notice: Class[Dummy]: Would have triggered 'refresh' from 1 events
notice: Stage[main]: Would have triggered 'refresh' from 1 events
notice: Finished catalog run in 2.77 seconds
</pre>

# Things to note
* I was not able to reproduce this with `puppet apply`, I think because of the 
source requirement.
* using the `content` paramater instead of the `source` paramater also did not 
reproduce this issue.
* All runs of puppet were done with `--noop`


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to