Saturday, 23 April 2016

getting started puppet modules.

getting started puppet modules.


Modules are self-contained bundles of code(each individual is manifest) and data.
REF : puppet
Nearly all Puppet manifests belong in modules.
deafault module directory : /etc/puppet/modules

1)puppet help module.
cmd : puppet help module

def : This subcommand can find, install, and manage modules from the Puppet Forge,
a repository of user-contributed Puppet code. It can also generate empty
modules, and prepare locally developed modules for release on the Forge.

USAGE: puppet module <action> [--environment production ]
[--modulepath $basemodulepath ]

2) module action.
ACTIONS:
  build        Build a module release package.
  changes      Show modified files of an installed module.
  generate     Generate boilerplate for a new module.
  install      Install a module from the Puppet Forge or a release archive.
  list         List installed modules
  search       Search the Puppet Forge for a module.
  uninstall    Uninstall a puppet module.
  upgrade      Upgrade a puppet module.

3) puppet module directory
module directory : /etc/puppet/modules

4) createing the boilerplate for your module
cmd : sudo puppet module generate my-voice
The below will render the metadata of the module my-voice
result :
{
  "name": "my-voice",
  "version": "0.1.0",
  "author": "my",
  "summary": null,
  "license": "Apache 2.0",
  "source": "",
  "project_page": null,
  "issues_url": null,
  "dependencies": [
    {"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"}
  ]
}


5) list the puppet module.

cmd : sudo puppet module list

Warning: Missing dependency 'puppetlabs-stdlib':
  'my-voice' (v0.1.0) requires 'puppetlabs-stdlib' (>= 1.0.0)
/etc/puppet/modules
├── accounts (???)
└── my-voice (v0.1.0)

6) Install the module from the puppetlab
"puppetlabs-stdlib"
cmd : sudo puppet module install puppetlabs-stdlib
output :
Notice: Preparing to install into /etc/puppet/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
└── puppetlabs-stdlib (v4.11.0)

7) search puppet module in puppetlabs.
output :
Notice: Searching https://forgeapi.puppetlabs.com ...
NAME                   DESCRIPTION                                                                             AUTHOR        KEYWORDS
sharumpe-apache2       Module to manage Apache2 v2.4 in OpenSuSE 13.1                                          @sharumpe
puppetlabs-apache      Installs, configures, and manages Apache virtual hosts, web services, and modules.      @puppetlabs   web httpd rhel apache2 ssl wsgi proxy
nodes-php              Puppet module to manage PHP, PECL & PEAR on debian / ubuntu - easily expandable to ...  @nodes        php pecl pear apc curl gd ssh2 apache2 fpm
saz-php                UNKNOWN                                                                                 @saz          apache debian ubuntu php apache2 fpm cli
mstanislav-apache_yum  UNKNOWN

8) install puppetlabs-apache.
sudo puppet module install puppetlabs-apache

a) sudo puppet module install puppetlabs-apt
Notice: Preparing to install into /etc/puppet/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
└─┬ puppetlabs-apt (v2.2.2)
  └── puppetlabs-stdlib (v4.11.0)


9) puppet module upgrade.
cmd : sudo puppet module upgrade puppetlabs-apt

Could not generate directory puppet

Error: Could not generate directory "voice", you must specify a dash-separated username and module name.
Error: Try 'puppet help module generate' for usage.

cmd : sudo puppet module generate voice

solution :  sudo puppet module generate my-voice

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.