Search This Blog

Showing posts with label puppet. Show all posts
Showing posts with label puppet. Show all posts

Wednesday, July 6, 2011

Puppet Server and Client Installation and Configuration Version 2.7.1

Puppet Server & Client Installation & Configuration Version 2.7.1

Server Side Installation

Host Name: PuppetMaster

ruby-1.8.5-5.el5_4.8
ruby-libs-1.8.5-5.el5_4.8
Facter 1.6.0 (tar+gzip)
(http://www.puppetlabs.com/misc/download-options/)
puppet-2.7.1 (tar.gz)
(http://www.puppetlabs.com/misc/download-options/ )

Note :
Please follow above sequence for installation.)

A supported Ruby version. Ruby 1.8.5, 1.8.7, and 1.9.2 are fully supported (with a handful of known issues under 1.9.2); Ruby 1.8.1 is supported on a best-effort basis for agent use only. Other versions of Ruby are used at your own risk, and Ruby 1.8.6, 1.9.0, and 1.9.1 are not recommended for compatibility reasons.

To avoid any certification error Make sure following criteria’s are full filled
1) Make sure the time on puppet Server and puppet client is in sync.
2) Make sure that /etc/hosts file has proper entry on both puppet client and puppet server.

Installation Steps:

1) ruby-1.8.5-5.el5_4.8
# yum install ruby
Confirm the installation :
# rpm -qa | grep ruby
ruby-1.8.5-5.el5_4.8
ruby-libs-1.8.5-5.el5_4.8
# ruby --version
ruby 1.8.5 (2006-08-25) [i386-linux]

2) ruby-libs-1.8.5-5.el5_4.8
will get installed if you run yum install ruby.

4) Facter 1.6.0 (tar+gzip)
#gunzip facter-1.6.0.tar.gz
#tar -xvf facter-1.6.0.tar
#cd facter-1.6.0
#ruby install.rb
Confirm the installation.
# facter --version
1.6.0


5) puppet-2.7.1 (tar.gz)
#gunzip /install/puppet-2.7.1.tar.gz
#tar -xvf puppet-2.7.1.tar
#cd puppet-2.7.1
#ruby install.rb
Confirm the installation.
# puppet --version
2.7.1
#puppetmasterd --version
2.7.1
#puppetd --version
2.7.1
#puppetca --version
2.7.1


Configuration:
Step 1: Create manifests folder
#mkdir -p /etc/puppet/manifests

Step 2: place your site.pp file into it.
Content of site.pp file
{ "/etc/sudoers":
owner => root,group => root, mode => 440
}
Above lines ensures that /etc/sudoers files at client meets following requirement.
owner = root, group = root, mode = 440
Step 3: Start the puppet master.

# puppet master --mkusers
Note: Example given here demonstrates following
the basic puppet (2.7.1)
setup Getting started with puppet (2.7.1)
(A simple check to see the file permission is achieved through puppet)

Client Side Installation

Installation Steps:
Note :
There are no separate steps for puppet client installation. Whatever Installation steps are performed in Puppet Server needs to be done in puppet client as well.

Configuration Step

Step 1:

Run following command to implement the rules defined at Puppet server.

# puppet agent --server puppetmaster --waitforcert 60 –test

info: Creating a new SSL key for puppetclient.domain.com

warning: peer certificate won't be verified in this SSL session

info: Caching certificate for ca

warning: peer certificate won't be verified in this SSL session

warning: peer certificate won't be verified in this SSL session

info: Creating a new SSL certificate request for puppetclient.domain.com

info: Certificate Request fingerprint (md5): 72:C6:73:89:B9:69:D9:8D:93:69:C3:69:14:AD:7E:E2

warning: peer certificate won't be verified in this SSL session

warning: peer certificate won't be verified in this SSL session

warning: peer certificate won't be verified in this SSL session


Note:
For the First run you will need to register your client at server.
(Read further in this article to see how to register your client at server.)

After registration of client on Server you should get following response.

# puppet agent --server PuppetMaster --waitforcert 60 --test

info: Caching catalog for puppetclient.domain.com

info: Applying configuration version '1309406496'

info: Creating state file /var/lib/puppet/state/state.yaml

notice: Finished catalog run in 0.05 seconds

As /etc/sudoers file meet the puppet servers manifest we didn’t notice any change in above output.

# ls -ltr /etc/sudoers

-r--r----- 1 root root 3185 Jan 22 2009 /etc/sudoers

To actually see the changes at puppet client lets modify /etc/sudoers file .

[root@puppetclient tmp]# chmod 777 /etc/sudoers

[root@puppetclient tmp]# chown ftp:root /etc/sudoers

[root@puppetclient tmp]# ls -ltr /etc/sudoers

-rwxrwxrwx 1 ftp root 3185 Jan 22 2009 /etc/sudoers

Now when the permissions on /etc/sudoers is changed on puppet client .

We will run the command once again and check the output.

# puppet agent --server PuppetMaster --waitforcert 60 --test

info: Caching catalog for puppetclient.domain.com

info: Applying configuration version '1309406496'

notice: /Stage[main]//File[/etc/sudoers]/owner: owner changed 'ftp' to 'root'

notice: /Stage[main]//File[/etc/sudoers]/mode: mode changed '777' to '440'

notice: Finished catalog run in 0.11 seconds

Now check the permission.

[root@puppetclient tmp]# ls -ltr /etc/sudoers

-r--r----- 1 root root 3185 Jan 22 2009 /etc/sudoers

As you can see puppet master has implemented the rule on puppet client.


Register puppet client on puppet server:

Whenever a puppet client request for puppet certificate for the first time, client won’t get it unless server signs clients certificate at server end.

Here are the steps to sign clients certificate at server end.

Step 1:

List the available certificates

# puppetca -l

puppetclient.domain.com

Step 2:

Sign them

# puppetca -s puppetclient.domain.com

notice: Signed certificate request for puppetclient.domain.com

notice: Removing file Puppet::SSL::CertificateRequest puppetclient.domain.com at '/etc/puppet/ssl/ca/requests/puppetclient.domain.com.pem'

Note:
This is the default behavior and can be changed . But for the security reason its recommended not to set the server on auto signing mode.


Monday, June 20, 2011

Puppet Configuration and Installation.

Puppet server is used to implement mass changes throughout the organization.

For example:
If a Organization requires you to disable ctr+alt+del on all of its servers by commenting
ca::ctrlaltdel:/sbin/shutdown -t3 -r now line of /etc/inittab file.

You will end up modifying /etc/inittab file of each and every linux distribution.

However the task will be easily done if you install puppet server all you need to do is to keep a copy of /etc/inittab on puppet server and then distribute it on linux distributions throughout your organization(provided they all have same version of /etc/initab files) .
There is lot other things that can be implemented using puppet .

For a basic configuration please refer the below article.

Server Side configuration:
Make sure you have following rpms .

ruby-lib
ruby
facter
puppet-server
puppet

# rpm -ivh ruby-libs-1.8.6.111-1.i686.rpm
Preparing... ########################################### [100%]
1:ruby-libs ########################################### [100%]
# rpm -ivh ruby-1.8.6.111-1.i686.rpm
Preparing... ########################################### [100%]
1:ruby ########################################### [100%]
# rpm -ivh facter-1.5.1-1.el5.noarch.rpm
Preparing... ########################################### [100%]
1:facter ########################################### [100%]
# rpm -ivh puppet-0.24.5-1.el5.noarch.rpm
Preparing... ########################################### [100%]
1:puppet ########################################### [100%]
# rpm -ivh puppet-server-0.24.5-1.el5.noarch.rpm
Preparing... ########################################### [100%]
1:puppet-server ########################################### [100%]

After installing the necessary rpms Now its time to configure the server.

Store all your files at following location(If the location doesnt exists then create it using # mkdir -p /etc/puppet/files).
/etc/puppet/files
We will store /etc/inittab file (with ctr+alt+del disabled) in above location .

Now we will create /etc/puppet/manifests/site.pp file.
This file holds all the puppet rule in form of classes.

class inittab_implement {
file { "/etc/inittab": #This file will be modified at client
ensure => present, #Check file existence . if not exists ,creates the file
mode => 744, #Permission
owner => root, #Ownership
group => root, #Group Owner
source => "puppet:///files/inittab" #source motd file
}
}
node 'default' {
include inittab_implement
}

Now the last step is to modify /etc/puppet/fileserver.conf.
This file ensures
1) Default location of puppet files.
2) which client machines should be allowed to get service from puppet server(This can be different on what is given in below example depending upon your network configuration).

edit the file and add following .
[files]
path /etc/puppet/files
allow 10.0.0.0/8

Start the puppetmaster service on server.

#service puppetmaster start
It would be nice if you add it to startup.
#chkconfig puppetmaster on
This is all about Server configuration now lets talk about client configuration.

Client Side configuration:
Make sure you have following rpms .

ruby-libs
ruby
facter
puppet

# rpm -ivh ruby-libs-1.8.6.111-1.i686.rpm
Preparing... ########################################### [100%]
1:ruby-libs ########################################### [100%]
# rpm -ivh ruby-1.8.6.111-1.i686.rpm
Preparing... ########################################### [100%]
1:ruby ########################################### [100%]
# rpm -ivh facter-1.5.1-1.el5.noarch.rpm
Preparing... ########################################### [100%]
1:facter ########################################### [100%]
# rpm -ivh puppet-
puppet-0.24.5-1.el5.noarch.rpm puppet-server-0.24.5-1.el5.noarch.rpm
# rpm -ivh puppet-0.24.5-1.el5.noarch.rpm
Preparing... ########################################### [100%]
1:puppet ########################################### [100%]

Now edit the /etc/puppet/puppet.conf file and add the below parameter:
server = PuppetMaster.domain.com #(Host name of my puppet server is PuppetMaster)
Make sure you have proper entry in /etc/host file on both puppet server and puppet client side.

Edit /etc/sysconfig/puppet file as mentioned below.

# The puppetmaster server
PUPPET_SERVER=PuppetMaster.domain.com

# If you wish to specify the port to connect to do so here
#PUPPET_PORT=8140

# Where to log to. Specify syslog to send log messages to the system log.
PUPPET_LOG=/var/log/puppet/puppet.log

# You may specify other parameters to the puppet client here
PUPPET_EXTRA_OPTS=--waitforcert=60 #this defines the time interval for puppet client to look for any update on puppet server.

For testing purpose the time is made as 1 minute you may set it little higher once the testing is done.

Now start the puppet service and add it on startup
# service puppet start
# chkconfig puppet on


You should now be able to run below command.
# puppetd --server puppetmaster.domain.com --waitforcert 60 --test

Unfortunately i was getting below error .
You may get this kind of error when both server and client time is not sync.(source google)
So i synced the time
Yet i was facing the same issue.
The problem was with the clients ssl certificate so i deleted the client cert using
# rm -rf /var/lib/puppet/ssl/

Next time when i run the command i got the following output.
So it has created new certificate.
# puppetd --server puppetmaster.domain.com --waitforcert 60 --test
info: Creating a new certificate request for test-ovs-2.domain.com
info: Creating a new SSL key at /var/lib/puppet/ssl/private_keys/test-ovs-2.domain.com.pem
warning: peer certificate won't be verified in this SSL session
notice: Did not receive certificate
notice: Set to run 'one time'; exiting with no certificate

warning: Certificate validation failed; considering using the certname configuration option
err: Could not retrieve catalog: Certificates were not trusted: certificate verify failed
warning: Not using cache on failed catalog

Now run the below command on puppet server.
It should now list the puppet client.
# puppetca --list
puppetclient.domain.com
Now sign the puppet client using
# puppetca --sign test-ovs-2.domain.com
Signed test-ovs-2.domain.com

Now try to execute previous command on client.
# puppetd --server puppetmaster.domain.com --waitforcert 60 --test
warning: peer certificate won't be verified in this SSL session
notice: Got signed certificate
info: Caching catalog at /var/lib/puppet/localconfig.yaml
notice: Starting catalog run
53c53
< x:5:respawn:/etc/X11/prefdm -nodaemon
---
> #x:5:respawn:/etc/X11/prefdm -nodaemon
info: Filebucket[/var/lib/puppet/clientbucket]: Adding /etc/inittab(5528f318b4fa5604efe51f3a8c5ca734)
info: //Node[default]/inittab_implement/File[/etc/inittab]: Filebucketed to with sum 5528f318b4fa5604efe51f3a8c5ca734
notice: //Node[default]/inittab_implement/File[/etc/inittab]/source: replacing from source puppet:///files/inittab with contents {md5}a43ac1c17a59b1facea7db112e69fb42
notice: Finished catalog run in 0.38 seconds

Now check the /etc/inittab file on client machine it should match to puppet server's(/etc/puppet/files/inittab) file.

I hope this article solved your basic queries over puppet configuration and installation.