Featured Post

Directory environments in Puppet

Environments are individual groups of Puppet agents each environment have there own completely different manifests and module-paths. This basically is useful for testing changes to our Puppet code before implementing them on production machines. There are two types of implementation of environments structure in Puppet one if directory based and another is config file based here we will see bit of an insight about directory based. As usual for more information about this you can visit puppetlabs official website. On the master node: Append following details in puppet.conf which is placed under /etc/puppet or /etc/puppetlabs/puppet:     Under [main] section add a variable called confdir with value as /etc/puppet or /etc/puppetlabs/puppet     confdir=/etc/puppet Then add information regarding environments/manifests and modulepath in it.      #environments     environmentpath = $confdir/environments     default_manfiest = $confdir/manifests     basemodulepath =

puppet resource???

*Resources in Puppet "puppet resource"*

Understanding Resources is fundamental to understanding how Puppet works. Resources are like building blocks. They can be combined to model the expected state of the systems you manage.

 For more information about the resources in puppet you can fire "puppet resource -h" on CLI.

This command transforms the current system state into puppet code also it has the ability to modify the current state of the system.

Syntax:

resource_type { 'resource_name'
  attribute => value
  ...
}


Below are the few examples:
  • To see all the users in the machine.
    • [root@puppet ~]# puppet resource user 
  • To see a particular user in the machine.
    •  [root@puppet ~]# puppet resource user sunny
      user { 'sunny':
        ensure           => 'present',
        comment          => 'Sunny_B',
        gid              => '501',
        home             => '/home/sunny',
        password         => '!!',
        password_max_age => '99999',
        password_min_age => '0',
        shell            => '/bin/bash',
        uid              => '501',
      }
      [root@puppet ~]#
  •  To see all the host entries in /etc/hosts.
    • [root@puppet ~]# puppet resource host
  • To see a particular host entry.
    •  [root@puppet ~]# puppet resource host kubuntu
      host { 'kubuntu':
        ensure       => 'present',
        host_aliases => ['kubuntu14.sunny.com'],
        ip           => '192.168.122.179',
        target       => '/etc/hosts',
      }
      [root@puppet ~]#
  •  To see all the packages installed in the machine.
    • [root@puppet ~]# puppet resource package
  • To see information about a particular package.
    •  [root@puppet ~]# puppet resource package httpd
      package { 'httpd':
        ensure => '2.2.15-15.el6',
      }
      [root@puppet ~]#
  •  To see status of all the services in the machine.
    • [root@puppet ~]# puppet resource service
  • To see status of a particular service in the machine suppose httpd.
    •  [root@puppet ~]# puppet resource service httpd
      service { 'httpd':
        ensure => 'running',
        enable => 'true',
      }
  •  To see all the mount points.
    • [root@puppet ~]# puppet resource mount
  • To see a particular mount point suppose / [where / is mounted].
    •  [root@puppet ~]# puppet resource mount /
      mount { '/':
        ensure  => 'mounted',
        device  => '/dev/mapper/vg_rhel6-lv_root',
        dump    => '1',
        fstype  => 'ext4',
        options => 'defaults',
        pass    => '1',
        target  => '/etc/fstab',
      }
      [root@puppet ~]#
To see what all resource types are accepted in puppet you can fire "puppet resource --types".


Comments

Popular posts from this blog

Exec in Puppet

Un-revoke the revoked certificate in Puppet

Dry run in Puppet --noop