Could not find resource 'File[/etc/logrotate.d/syslog]

31 views
Skip to first unread message

Dan Crisp

unread,
Oct 22, 2019, 9:27:05 PM10/22/19
to Puppet Users
Hi,

I'm seeing the following error when running the agent on a server:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Could not find resource 'File[/etc/logrotate.d/syslog]' in parameter 'subscribe' (file: /etc/puppetlabs/code/environments/production/modules/base/manifests/syslog.pp, line: 21) on node lhcsrvmtrrsl01.fixnetix.com

I want the logrotate command to run every time there is a change to the /etc/logrotate.d/syslog file.  Thought this could be achieved via the following:

  exec { 'LogRotate':
    path        => '/usr/sbin',
    command     => 'logrotate -vdf /etc/logrotate.d/syslog 2>/dev/null',
    subscribe   => File['/etc/logrotate.d/syslog'],
    refreshonly => true,
  }

I can't work out why the agent is complaining re Could not find resource 'File[/etc/logrotate.d/syslog]'

# puppet resource file /etc/logrotate.d/syslog
file { '/etc/logrotate.d/syslog':
  ensure   => 'file',
  content  => '{md5}e59f6816e9fcd21174501313720c660f',
  ctime    => '2019-10-22 21:36:25 +0100',
  group    => 0,
  mode     => '0644',
  mtime    => '2019-10-22 21:36:25 +0100',
  owner    => 0,
  selrange => 's0',
  selrole  => 'object_r',
  seltype  => 'etc_t',
  seluser  => 'system_u',
  type     => 'file',
}

Ben Ford

unread,
Oct 22, 2019, 10:22:50 PM10/22/19
to puppet...@googlegroups.com
Hi Dan!

When you subscribe to another resource like subscribe => File['/etc/logrotate.d/syslog'], the key is that you're not actually subscribing to the file on disk. You're subscribing to another Puppet resource, of type File and with a title of '/etc/logrotate.d/syslog'. Any time that Puppet makes changes to the resource, that notification will trigger.

Here's a graphic that shows how the relationship works. References in the Puppet code point to resource declarations in Puppet code, not to the artifacts on the system that are managed by those resource declarations.

reference_manifest.png

This means that unless you're actually managing that file with Puppet code, the relationship won't work.


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/482e3b96-c20c-4517-85c9-dc437f28c56c%40googlegroups.com.

Dan Crisp

unread,
Oct 23, 2019, 12:17:11 PM10/23/19
to Puppet Users
Perfect!!  Thanks Ben.  
To unsubscribe from this group and stop receiving emails from it, send an email to puppet...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages