Recently, I have been introduced to Puppet script which has been used in my work environment has proven its importance.
"Puppet manages your servers: you describe machine configurations in an easy-to-read declarative language, and Puppet will bring your systems into the desired state and keep them there."
This tutorial will show you how to create a simple puppet script to build a LAMP system which is the base for any web system. The components required for a web system such as apache, mysql etc are all available as modules from Puppet Forge
First things first, install puppet using yum
yum install puppet-server puppet
By default puppet is installed in
/etc/puppet
path.Now onto installing web server components, you have to be in
/etc/puppet/modules
path and run the following commands.
puppet module install puppetlabs/apache
puppet module install puppetlabs/mysql
puppet module install rabinshr/rabinshr_phpmyadmin_1_0
The above commands will install puppet modules for apache and mysql. To learn more about installing modules, visit the documentation here.
We now have the modules ready, its now time to create a manifest file that will use these modules and create a web server. My manifest file has the following code:
node puppet{
$db_password = 'db_password_here'
include apache
include apache::mod::php
class{'mysql::server':
config_hash => {'root_password' => $db_password}
}
class{'mysql::php':}
class { 'phpmyadmin':
db_user => '',
db_password => '',
blowfish => 'abcedf1234true',
}
}
To create a new database you can add the following code to your manifest:
mysql::db{'db_name_here':
user => 'root',
password => 'db_password_here'
}
To run this manifest, simply execute the following command.
puppet apply path_to_your_manifest_file
No comments:
Post a Comment