Today’s system engineers and still stuck with managing configurations using bash scripts??
Well, it does not sound good. Go and get everything puppetized !!
So first of all, why a configuration automation system and how does puppet play an important role in this context?
One of our web developers came to me and asked, “How can I quickly model a PHP application without having to bother you for a development environment?”
I thought it for a while and came to the conclusion that from developer’s point of view it is not feasible to ask for a new environment every time to do the work and being a system engineer i could think that the whole process of managing configurations manually is quite cumbersome task. Luckily, it does not have to be !! Here comes the existence of puppet with which i could get everything solved.
Puppet is a configuration management tool that is extremely powerful in deploying, configuring, managing, maintaining, a server machine.
So here you are : LAMP automation with puppet !!
Using this puppet module, any system engineer, or anyone for that matter, can quickly launch a LAMP environment in minutes to get them going on with applications at developer’s end.
BEFORE YOU BEGIN :
Before you go ahead with this module, make sure that you have puppet master and agent installed on your host machines and agent contains a certificate signed by the puppet master. All you need to do is to get this module installed either from github or puppetforge.
Puppet version >=3.4.0 & Ubuntu 14.04/12.04 is recommended for the following configurations.
PUPPET MASTER :
MANIFEST FILE : (The location where your puppet code is written.They are standard text files saved with .pp extensions )
Path => [/etc/puppet/modules/lamp/manifests/init.pp]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
class lamp { #execute ‘apt-get update’ exec { ‘apt-update’ : command => ‘/usr/bin/apt-get update’, before => Package[‘apache2’], } #install apache2 package package { ‘apache2’ : ensure => latest, require => exec[‘apt-update’], } #ensure apache2 service is running service { ‘apache2’ : ensure => running, require => Package[‘apache2’], } #install mysql-server package package { ‘mysql-server’ : ensure => latest, } #ensure mysql service is running service { ‘mysql’ : ensure => running, require => Package[‘mysql-server’], } # install php5 package package { ‘php5’ : ensure => latest, } # ensure info.php file exists file { ‘/var/www/html/info.php’: ensure => file, content => ‘<?php phpinfo(); ?>’, require => Package[‘apache2’], } } |
Now, you just need to include this file into your main manifests.
Path => /etc/puppet/manifests/site.pp
1 2 3 4 5 |
node default { include lamp } |
The above code signifies that lamp module containing the puppet code should be included for all the requesting puppet-clients. If you want to include your lamp module only for some specific nodes, you need to replace ‘default’ with the hostname of the requesting nodes.
To install the entire module from puppetforge :-
https://forge.puppetlabs.com/webkul/lamp
For reference :-
https://github.com/nainajohari/puppet-lamp
Now, you have to restart the service using the following command :-
1 |
service puppetmaster restart |
PUPPET AGENT :
First of all, you must ensure that puppet client is aware of its respective puppet master.To introduce a client machine to the puppet server,make an entry in client’s main configuration file as mentioned below :-
Path -> /etc/puppet/puppet.conf
1 |
server = puppetm |
where, puppetm is the hostname of the respective puppet master.
Now, puppet agent can send a request to puppet master using the following command :-
1 |
puppet agent --test |
Here, we have assumed that puppet agent contains a certificate signed by the puppet master.
By simply running this single command, the entire puppet code of master’s main manifests will be executed on puppet client.
Repeat the same for multiple puppet clients.