Saturday, 23 April 2016

getting started puppet manifest

getting started puppet manifest

1) check the default resources list for puppet.

cmd :
puppet resource [-h|--help] [-d|--debug] [-v|--verbose] [-e|--edit] [-p|--param parameter] [-t|--types] [-y|--to_yaml] type [name] [attribute=value ...]

REF : puppet

command : puppet resources --types

output :

augeas,computer,cron,exec,file,filebucket,group,host,interface,k5login,macauthorization,mailalias,maillist,mcx,mount,nagios_command
nagios_contact,nagios_contactgroup,nagios_host,nagios_hostdependency,nagios_hostescalation,nagios_hostextinfo,nagios_hostgroup,
nagios_service,nagios_servicedependency,nagios_serviceescalation,nagios_serviceextinfo,nagios_servicegroup,nagios_timeperiod
notify,package,resources,router,schedule,scheduled_task,selboolean,selmodule,service,ssh_authorized_key,sshkey,stage,tidy,user
vlan,whit,yumrepo,zfs,zone,zpool.

2) here in puppet, program are called as manifest.
ex : root.pp.

3) class can be defined as the resuseable component, can be called/used from any where.

def :

class classname {

puppet code

}

Friday, 22 April 2016

start puppet and check states of users


1)  start the puppet master.

cmd : systemctl start puppet

check process running on linux.
cmd : top (http://www.cyberciti.biz/faq/show-all-running-processes-in-linux/)

How to check processor and cpu details on Linux
cmd : lscpu
----------------------'
1) puppet will tell state of user.
cmd : puppet resource user root.

output :

user { 'root':
  ensure           => 'present',
  comment          => 'root',
  gid              => '0',
  home             => '/root',
  password         => '!!!!!!',
  password_max_age => '99999',
  password_min_age => '0',
  shell            => '/bin/bash',
  uid              => '12',
}
2) change state of shell command from bash to sh.
a) create a mnifest of the root user.

cmd : sudo puppet resource user root > root.pp

b) save and open the manifest file.

user { 'root':
  ensure           => 'present',
  comment          => 'root',
  gid              => '0',
  home             => '/root',
  password         => '!!!!!!',
  password_max_age => '99999',
  password_min_age => '0',
  shell            => '/bin/sh',
  uid              => '12',
}

c) apply the manifest

puppet apply root.pp

d) now check state of the user again.

cmd : puppet resource user root.

user { 'root':
  ensure           => 'present',
  comment          => 'root',
  gid              => '0',
  home             => '/root',
  password         => '!!!!!!',
  password_max_age => '99999',
  password_min_age => '0',
  shell            => '/bin/sh',
  uid              => '12',
}


3) now if we want to just simulate and dont want to change the state.

cmd :

a) vim root.pp

user { 'root':
  .
  .
  shell            => '/bin/bash',
  .
}
b) puppet apply root.pp  --noop (it show what all the changes might happen to the state if we use it)

REF  :
1) note there is not much of difference in bash/sh
2) puppet


puppet Resource Types reference

puppet resource [options]

--help

'--genconfig'.

* --debug:
  Enable full debugging.

* --edit:
  Write the results of the query to a file, open the file in an editor,
  and read the file back in as an executable Puppet manifest.

* --host:
  When specified, connect to the resource server on the named host
  and retrieve the list of resouces of the type specified.

* --help:
  Print this help message.

* --param:
  Add more parameters to be outputted from queries.

* --types:
  List all available types.

* --verbose:
  Print extra information.


EXAMPLE
-------
This example uses `puppet resource` to return a Puppet configuration for
the user `root`:

    $ puppet resource user root
    user { 'root':
     home => '/home/root',
     uid => '100',
     ensure => 'present',
     comment => 'root comments',
     gid => '1000',
     shell => '/bin/bash',
     groups => ['sysadmin','audio','video','puppet']
    }

Thursday, 21 April 2016

find puppet intalled in rhel linux

how to find the version  of puppet intalled in rhel linux

cmd : rpm -qa | grep puppet

puppetlabs-release-7-12.noarch
puppet-...x.noarch
puppet-server-x.x.x.x.noarch

know the linux version

how to know the linux version.
for kernel level.
1) uname -a
2) to know the redhat version then use.
cmd : cat /etc/redhat-release.

puppet Stages for Configuration Management

puppet has Two Stages for Configuration Management
Puppet configures systems in two main stages:

Compile a catalog
Apply the catalog
What is a Catalog?
A catalog is a document that describes the desired system state for one specific computer. It lists all of the resources that need to be managed, as well as any dependencies between those resources.

To compile a catalog, Puppet uses several sources of information. For more info, see the pages on

1) basics of the Puppet language
2) catalog compilation

puppet labs

puppeet lab :

ref: puppet 

try the emulator for getting basic.

1) If we want to see resources available on root user of linux machine.
cmd : puppet resource <user> <name of the user>
ex :  puppet resource user root

output :

st $: puppet resource user root

user { 'root':
 ensure          => 'present',
 comment         => 'root',
 home            => '/root',
 password        => '$1$v4K9E8Wj$gZIHJ5JtQL5ZGZXeqSSsd0',
}

Puppet is describing the current state of the root user in DSL(domain specific language).

The first line is telling us the resource type,in this case user, that the title of this user resource is root.
Then Puppet is displaying a list of attributes that describe the configuration of the root user.