Sunday, October 15, 2017

learn how to use facter in puppet.

=====================================================
Following practical will help you to know how to use facter in puppet.
=====================================================

Facter is command tool which provides the node specific information, which is used by puppet master for node segregation of spacfic content managment


[root@pupprdclt1 ~]# facter | egrep "family | hostname|kernelversion"
kernelversion => 2.6.32
  hostname => "pupprdclt1",
  family => "RedHat",
[root@pupprdclt1

===================================================================
Check squid is not installed on puppet agent node, and we will use above mentioned facters in manifest on master server for the code deployment.
 ====================================================================

[root@pupprdclt1 ~]# yum list squid
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos-hn.viettelidc.com.vn
 * extras: mirrors.vinahost.vn
 * updates: mirrors.viethosting.com
Available Packages
squid.x86_64                                                        7:3.1.23-24.el6                                                         base
[root@pupprdclt1




===================================================================
Go to the Puppetmaster node and create squid module using facter specification
===================================================================

[root@puppetmaster ~]# mkdir /etc/puppetlabs/code/environments/production/modules/squid

[root@puppetmaster ~]# cd /etc/puppetlabs/code/environments/production/modules/squid

[root@puppetmaster squid]#mkdir manifest

root@puppetmaster squid]# ls -l
total 12
drwxr-xr-x. 2 root root 4096 Oct 15 06:13 manifests


[root@puppetmaster squid]# cd manifests

[root@puppetmaster manifests]#



[root@puppetmaster manifests]#vi install.pp
class squid::install{
        if $osfamily == 'RedHat'{  <--------using RedHat facter output of osfamily
                        package{'squid':
                        ensure => installed,
                        }
        }
        elsif $osfamily == 'Debian'{
                package{'httpd':
                ensure => installed,
                        }
                }
}


[root@puppetmaster manifests]# vi init.pp
class squid{
        include squid::install             <------------- calling squid class
}

:x!

[root@puppetmaster manifests]#

[root@puppetmaster squid]#


[root@puppetmaster manifests]# ls -l *.pp
-rw-r--r--. 1 root root  39 Oct 15 06:34 init.pp
-rw-r--r--. 1 root root 187 Oct 15 06:26 install.pp
[root@puppetmaster manifests]#

-----------------------------------
Now go on client and call manifest
-----------------------------------
[root@pupprdclt1 ~]# puppet agent -tv
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for pupprdclt1.linuxchamps.com
Info: Applying configuration version '1508074488'
Notice: Hello World
Notice: /Stage[main]/Main/Notify[Hello World]/message: defined 'message' as 'Hello World'
Notice: /Stage[main]/Squid::Install/Package[squid]/ensure: created <-------- see installing Squid on
Notice: Applied catalog in 112.75 seconds
===================================================================
 Now check squid is installed or not on puppet client
===================================================================
[root@pupprdclt1 ~]# yum list squid
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos-hn.viettelidc.com.vn
 * extras: mirrors.vinahost.vn
 * updates: mirrors.viethosting.com
Installed Packages
squid.x86_64                                                        7:3.1.23-24.el6                                                 @base
[root@pupprdclt1 ~]#

Learning Puppet

[root@anujpupetmaster ~]# cd /tmp/puppet-enterprise-2015.3.3-el-6-x86_64
[root@anujpupetmaster puppet-enterprise-2015.3.3-el-6-x86_64]# ./puppet-enterprise-installer
========================================================================================================================================================================

Puppet Enterprise v2015.3.3 installer

Puppet Enterprise documentation can be found at http://docs.puppetlabs.com/pe/2015.3/

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

STEP 1: GUIDED INSTALLATION

Before you begin, choose an installation method. We've provided a few paths to choose from.

- Perform a guided installation using the web-based interface. Think of this as an installation interview in which we ask you exactly how you want to install PE. In
order to use the web-based installer, you must be able to access this machine on port 3000 and provide the SSH credentials of a user with root access. This method
will login to servers on your behalf, install Puppet Enterprise and get you up and running fairly quickly.

- Use the web-based interface to create an answer file so that you can log in to the servers yourself and perform the installation locally. If you choose not to use
the web-based interface, you can write your own answer file, or use the answer file(s) provided in the PE installation tarball. Refer to Answer File Installation
(http://docs.puppetlabs.com/pe/2015.3/install_automated.html), which provides an overview on installing PE with an answer file.

?? Install packages and perform a guided install? [Y/n] Y

Installing setup packages.

Please go to https://anujpupetmaster:3000 in your browser to continue installation. Be sure to use https:// and that port 3000 is reachable through the firewall.

Your infrastructure has finished installing.
Thank you for installing Puppet Enterprise!
[root@anujpupetmaster puppet-enterprise-2015.3.3-el-6-x86_64]#

kubernetes Pod Scheduling

 ===================   Deployment ================= 1.) Deployment without any nodeName or nodeSelector, pod will spread among all of the av...