manifest, vmware

Creating a manifest

Manifest is a data file which contains client configuration’s, written in Puppet’s declarative language or a Ruby DSL. The manifest file contains information about files, packages and configuration operations, how the system state should be! Mostly we make use of code (bash or python) to make changes on our system, with the use of manifest we declare how the system should be. This blog covers some basic manifest to create a directory as well as a file on the managed node.

I'm doing a lot with VMWare workstation; at the end of this blog I will install the packeges for the installation of VMWare tools with a manifest.

Manifest location:

Main puppet manifest file is located at

/etc/puppetlabs/code/environments/production/manifests/site.pp

Now add the following lines to the manifest to create a directory on the managed node.

If the node variable is not set, this manifest will apply to all the nodes connected to the puppet master (puppetmaster).

# vi /etc/puppetlabs/code/environments/production/manifests/site.pp
node 'puppetclient' { # Applies only to mentioned node; if nothing mentioned, applies to all.
file { '/tmp/puppettestdir': # Resource type file
ensure => 'directory', # Create as a diectory
owner => 'root', # Ownership
group => 'root', # Group Name
mode => '0755', # Directory permissions
}
}

Now, run the following command on the client node to retrieve the configurations.

# /opt/puppetlabs/bin/puppet agent --test

Output:

Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for puppetclient
Info: Applying configuration version '1472165498'
Notice:      /Stage[main]/Main/Node[puppetclient]/File[/tmp/puppettestdir]/ensure: created
Notice: Applied catalog in 0.03 seconds

Verify that directory has been created on the managed node.

[root@client ~]# ls -ld /tmp/puppettestdir
drwxr-xr-x. 2 root root 6 Nov 14 11:36 /tmp/puppettestdir

Let’s do the test once again by writing the manifest for creating a file with content into it.

# vi /etc/puppetlabs/code/environments/production/manifests/site.pp
node 'puppetclient' { # Applies only to mentioned node; if     nothing mentioned, applies to all.
file { '/tmp/puppettestfile': # Resource type file
ensure => 'present', # Make sure it exists
owner => 'root', # Ownership
group => 'root', # Group Name
mode => '0644', # File permissions
content => "This File is created by Puppet Server\n"
}
}

In this example we use \n for a line feed, the following escape sequences are also available:

  • \n Line feed
  • \r Carriage return (necessary in Windows files)
  • \s Space
  • \t Tab character

You can go to the client machine command and retrieve the catalog as shown in the previous example.
That’s all, now you have successfully configured puppet server and a puppet agent.

VMWare tools installation on puppetclient:

Now it is the time to install prerequisites packages for the installation of VMWare-tools in a manifest file.

# vi /etc/puppetlabs/code/environments/production/manifests/site.pp
node 'puppetclient' { # Applies only to mentioned node; if     nothing mentioned, applies to all.
file { '/tmp/puppettestfile': # Resource type file
ensure => 'present', # Make sure it exists
owner => 'root', # Ownership
group => 'root', # Group Name
mode => '0644', # File permissions
content => "This File is created by Puppet Server\n"
}
# Here we install prerequisites packeges for vmware
package { 'perl': ensure => 'installed'}
package { 'gcc': ensure => 'installed'}
package { 'make': ensure => 'installed'}
package { 'kernel-headers': ensure => 'installed'}
package { 'kernel-devel': ensure => 'installed'}
package { 'net-tools': ensure => 'installed'}
}

Output:

# /opt/puppetlabs/bin/puppet agent --test
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for slotpuppetclient
Info: Applying configuration version '1479121968'
Notice:      /Stage[main]/Main/Node[slotpuppetclient]/Package[perl]/ensure: created
Notice: /Stage[main]/Main/Node[slotpuppetclient]/Package[gcc]/ensure: created
Notice: /Stage[main]/Main/Node[slotpuppetclient]/Package[kernel-devel]/ensure: created
Notice: /Stage[main]/Main/Node[slotpuppetclient]/Package[net-tools]/ensure: created
Notice: Applied catalog in 73.65 seconds

We have installed the prerequisites packeges for VMWare-tools. You could now install VMWare-tools on you server.

cd /tmp/
mount /dev/cdrom /mnt/
tar -xvf /mnt/VMwareTools-x.x.x-xxxxx.tar.gz
cd vmware-tools-distrib/
[root@puppetclient vmware-tools-distrib]# ./vmware-install.pl
open-vm-tools are available from the OS vendor and VMware recommends using
open-vm-tools. See http://kb.vmware.com/kb/2073803 for more information.
Do you still want to proceed with this legacy installer? [no] yes

Now we have succesfully installed VMWare tools on our puppetclient. In my next blog I'm going to install docker with a manifest by using the puppetforge repository.