In today’s session, we are going to quickstart writing a basic puppet module. A Very simple example could be creating a directory on remote Linux machines. Hence, we go further with this.
Aim – How to create a directory through Puppet?
Steps:
1.Create a puppet module called ajeet-environment:
[root@puppetmaster modules]# puppet module generate ajeet-environment
- Under /etc/puppetlabs/puppet/modules/ajeet-environment/manifests , ensure that these files are present:
[root@puppetmaster manifests]# pwd
/etc/puppetlabs/puppet/modules/ajeet-environment/manifests
[root@puppetmaster manifests]# ls -la
total 16
drwxr-xr-x. 2 root root 4096 Jan 20 00:50 .
drwxr-xr-x. 5 root root 4096 Jan 20 00:43 ..
-rw-r–r–. 1 root root 289 Jan 20 00:50 createafile.pp
-rw-r–r–. 1 root root 1015 Jan 20 00:38 init.pp
- The Contents should look like:
lscreateafile.pp init.pp[root@puppetmaster manifests]# cat createafile.pp
class createafile{ # create a directory file { “/etc/sites-conf”: ensure => “directory”, } # a fuller example, including permissions and ownership file { “/var/log/admins-app-log”: ensure => “directory”, owner => “root”, group => “wheel”, mode => 750, } } |
File: init.pp
class ajeet-environment {include createafile} |
File: site.pp
node ‘puppetagent1.cse.com’ {#include ajeet-environment
} |
Machine: Puppetagent1.cse.com
Hence the directory gets created on the puppetagent.
Comments are closed.