Search code examples
puppet

Puppet agent can't be deployed module from master


I'm just start learning Puppet, really new to this world. I'm using puppet 2.7.26 on my two learning VMs -- puppet-master 192.168.160.131 eisen-suse11 192.168.160.129 Follow the turial, I've signed the node "eisen-suse11" to puppet-master successfully--

puppet-master:/etc/puppet/modules/motd/manifests # puppet cert --list --all
+ "eisen-suse11"         (A0:7F:E2:77:30:9A:96:E3:79:FD:F7:1E:59:35:5B:1E)
+ "puppet-master"        (38:90:B5:8A:68:8A:A7:44:8A:2F:07:D3:F3:AC:E8:80) (alt names: "DNS:puppet", "DNS:puppet-master", "DNS:puppet-master.suse11", "DNS:puppet.suse11")
+ "puppet-master.suse11" (5D:9E:A4:D9:0C:5F:69:07:FA:55:13:C3:38:6D:9B:26)

Then follow the book, I write a module -- motd -- which should put a file to client node --

puppet-master:/etc/puppet/modules/motd/manifests # cat init.pp
class motd{
      package{ 'setup':
      ensure => present,
  }
  file{ '/etc/motd':
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0644',
        source  => "puppet://$puppetserver/modules/motd/etc/motd",
        require => Package['setup']
    }
}
puppet-master:/etc/puppet/modules/motd/manifests # cat site.pp
$puppetserver='puppet-master.suse11'
node 'eisen-suse11'{
    include motd
}

But when I tested "puppet agent --test --trace" on the client node -- eisen-suse11 --- it's all quiet --

eisen-suse11:~ # puppet agent --test --trace
info: Caching catalog for eisen-suse11
info: Applying configuration version '1633779962'
notice: Finished catalog run in 0.01 seconds

    eisen-suse11:~ # ls /etc/motd
    ls: cannot access /etc/motd: No such file or directory

   That "/etc/motd" is not copied from puppet-master -- 
   Does anyone can help? Any idea would be appreciated.  

RGS Eisen


Solution

  • The problem is that your node is receiving an empty catalog, which is happening because you put your site.pp file in the wrong place. Puppet will not find it inside the module. It has been a very long time since I wrote code for Puppet 2 (and I hung on to that version much longer than was healthy), but as I recall, the correct directory for that file would be /etc/puppet/manifests.

    But again, as I wrote in comments, Puppet 2 is utterly obsolete and well past the end of its life. Ditch it, and also ditch any books you have that teach it. The only reason I can think of to learn this version of Puppet is that you have an existing legacy infrastructure that you are obligated to maintain, but if you are faced with such a Puppet code base in 2021 then it would be best to rewrite from scratch for Puppet 7.