Join our Discord Server
Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Distinguished Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 700+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 9800+ members and discord server close to 2600+ members. You can follow him on Twitter(@ajeetsraina).

Learn Puppet With Me – Day 4

38 sec read

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

ajeet-environment

  1. 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

  1. 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

puppetagent-1

Hence the directory gets created on the puppetagent.

Have Queries? Join https://launchpass.com/collabnix

Ajeet Raina Ajeet Singh Raina is a former Docker Captain, Community Leader and Distinguished Arm Ambassador. He is a founder of Collabnix blogging site and has authored more than 700+ blogs on Docker, Kubernetes and Cloud-Native Technology. He runs a community Slack of 9800+ members and discord server close to 2600+ members. You can follow him on Twitter(@ajeetsraina).
Join our Discord Server