Posts

Showing posts with the label module

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

Manifests

Manifests Puppet programs are called “manifests,” and they use the .pp file extension. The core of the Puppet language is the resource declaration. A resource declaration describes a desired state for one resource. (Manifests can also use various kinds of logic: conditional statements, collections of resources, functions to generate text, etc. We’ll get to these later.) [root@server demo_manifests]# cat add_user.pp user { 'optimus':   ensure => 'present',   home   => '/home/optimus',   shell  => '/bin/bash', } [root@server demo_manifests]# [root@server demo_manifests]# puppet apply /root/Desktop/demo_manifests/add_user.pp notice: /Stage[main]//User[optimus]/ensure: created notice: Finished catalog run in 0.21 seconds [root@server demo_manifests]# Puppet Apply Like resource in the last chapter, apply is a Puppet subcommand. It takes the name of a manifest file as its argument, and enforces the desired state descri...

Dry run in Puppet --noop

 Dry run in puppet is a powerful feature given by puppet. This basically is used to test your Puppet manifests on any of the environment without actually making any changes to the machine. To dry-run Puppet, --noop flag needs to be used. Puppet’s ‘noop’ (no-operation) mode shows you what would happen, but actually doesn’t do anything :) This basically helps us for debugging stuff. For instance: [root@puppet manifests]# puppet apply site.pp --noop notice: /Stage[main]/Sudo/File[/etc/sudoers]/content: current_value {md5}e81452ad78198a79772447b1f2b3b614, should be {md5}e2d690ebe349d93efa84146eb854c987 (noop) notice: Class[Sudo]: Would have triggered 'refresh' from 1 events notice: /Stage[main]/Ssh::Service/Service[sshd]/ensure: current_value stopped, should be running (noop) notice: Class[Ssh::Service]: Would have triggered 'refresh' from 1 events notice: Stage[main]: Would have triggered 'refresh' from 2 events notice: Finished catalog run in 2.75 seco...

Creating a module in Puppet

Here we will try to create a module[sudo] and see how we can use it. For more information about the structure of a module you can check this link . Our mission is to add users sunny and bbee to the sudoers file. Firstly create a directory called sudo in /etc/puppet/modules/ directory. This is basically your module name. [root@puppet modules]# mkdir sudo Now create three sub-directories in it as manifests, files, templates. [root@puppet modules]# mkdir manifests files templates So your current structure is somewhat like this: sudo/ ├── files ├── manifests └── templates 3 directories, 0 files The first and foremost part is to check and install[If not installed] the necessary package. package { 'sudo':                 ensure => present,                 } The above code states that package sudo should be installed in ...

Puppet installation on agent/server

Puppet can be used as a standalone model or as agent/server model. There are basically 2 types of puppet version available in market. Free version of puppet. Enterprise version of puppet which is also know as puppet-enterprise. Here we will be installing the free version of puppet. 0. Enable EPEL repo, you can find the latest version of EPEL on below URL: https://fedoraproject.org/wiki/EPEL 1. Install prerequisites before installing puppet [root@rhel6 ~]# yum install ruby-shadow ruby ruby-libs 2. Resolve the dependencies like ruby(selinux). 3. Install puppetmaster and facter on the server node. [root@rhel6 ~]# yum install puppet-server facter 4. Install puppet and facter on the agent node. [root@rhel6 ~]# yum install puppet facter Once these packages are installed on both the machines. Make sure that your agent node can ping the server node with the name as puppet. [root@rhel6 ~]# ping puppet PING puppet (192.168.122.14) 56(84) bytes of data. 64 bytes fr...

puppet describe???

*Describe sub-command in Puppet "puppet describe" * The puppet describe sub-command can list info about the currently installed resource types on a given machine. This is a built in documentation and a great source of information. It helps us to know the behavior of types, their properties and parameters. "puppet describe -l" — List all of the resource types available on the system. "puppet describe -s <TYPE>" Print short information about a type, without describing every attribute "puppet describe <TYPE>" Shows each and every information about the type which you are referring too. [root@puppet ~]# puppet describe -l These are the types known to puppet: augeas          -  Apply a change or an array of changes to the ... computer        - Computer object management using DirectorySer ... cron            -  Installs a...

puppet apply???

*Apply sub-command in Puppet "puppet apply"* This is the standalone puppet execution tool which is used to apply individual manifests. It is an application that complies and manages configuration on node. Point to note is puppet apply never runs as a daemon like puppet agent. It always runs like a single process which complies a catalog then applies it send a report that's it. Most important option with puppet apply command is modulepath. Suppose you are firing puppet apply XYZ.pp file then it will take the module location as /etc/puppet/modules by default but if in case your modules are there in some other directory suppose /root/puppet-modules then you can use "modulepath" with this location to ask puppet to use it. Running a puppet apply command to apply the changes to the machine with site.pp manifest. [root@puppet manifests]# puppet apply site.pp notice: /Stage[main]/Sudo/File[/etc/sudoers]/content: content changed '{md5}e81452ad78198a...

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

Introduction to Puppet

Puppet is an open source configuration management utility. It runs on mostly all Unix/Linux flavors as well as on Microsoft Windows, and includes its own declarative language to describe system configuration. With Puppet, repetitive tasks are automated away, so sysadmins can quickly deploy business applications, scaling easily from tens of servers to thousands, both on-premise and in the cloud. Puppet is written in a declarative language, means you tell Puppet what results you want, rather than how to get there. Puppet is produced by Puppet Labs, founded by Luke Kanies in 2005. It is written in Ruby and released as free software under the GPL. Most of Puppet’s functionality comes from a single puppet command, which has many sub-commands. Most importantly there is a sub-command called resource. The resource subcommand can inspect and modify resources interactively. [root@server manifests]# puppet resource service service { 'NetworkManager':   ensure => 'r...