Basic Puppet
- Puppet - Facter & Facts
- Puppet - File Server
- Puppet - Module
- Puppet - Manifest Files
- Puppet - Coding Style
- Puppet - Validating Setup
- Installing & Configuring r10K
- Puppet - SSL Sign Certificate Setup
- Puppet - Agent Setup
- Puppet - Master
- Puppet - Environment Conf
- Puppet - Configuration
- Puppet - Installation
- Puppet - Architecture
- Puppet - Overview
Advanced Puppet
- Puppet - Live Project
- Puppet - RESTful API
- Puppet - Type & Provider
- Puppet - Environment
- Puppet - Custom Functions
- Puppet - Function
- Puppet - Classes
- Puppet - Template
- Puppet - Resource Abstraction Layer
- Puppet - Resource
Puppet Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Puppet - Vapdating Puppet Setup
In Puppet, the setup can be tested locally. Hence, once we have set up Puppet master and node, it’s time to vapdate the setup locally. We need to have Vagrant and Vagrant box installed locally, which helps in testing the setup locally.
Setting Up the Virtual Machine
As we are testing the setup locally, we do not actually require a running Puppet master. This means without actually running the Puppet master on the server, we can simply use Puppet to apply command for Puppet setup vapdation. Puppet apply command will apply changes from local/etc/puppet depending on the virtual machine’s hostname in the configuration file.
First step which we need to perform in order to test the setup is to build the following Vagrantfile and start a machine and mount the /etc/puppet folder into place. All the files which are required will be place inside the version control system with the following structure.
Directory Structure
- manifests - site.pp - modules - your modules - test - update-puppet.sh - Vagrantfile - puppet.conf
Vagrant File
# -*- mode: ruby -*- # vi: set ft = ruby : Vagrant.configure("2") do |config| config.vm.box = "precise32" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.provider :virtualbox do |vb| vb.customize ["modifyvm", :id, "--memory", 1028, "--cpus", 2] end # Mount our repo onto /etc/puppet config.vm.synced_folder "../", "/etc/puppet" # Run our Puppet shell script config.vm.provision "shell" do |s| s.path = "update-puppet.sh" end config.vm.hostname = "localdev.example.com" end
In the above code, we have used Shell provisioner in which we are trying to run a Shell script named update-puppet.sh. The script is present in the same directory where the Vagrant file is located and the content of the script are psted below.
!/bin/bash echo "Puppet version is $(puppet --version)" if [ $( puppet --version) != "3.4.1" ]; then echo "Updating puppet" apt-get install --yes lsb-release DISTRIB_CODENAME = $(lsb_release --codename --short) DEB = "puppetlabs-release-${DISTRIB_CODENAME}.deb" DEB_PROVIDES="/etc/apt/sources.pst.d/puppetlabs.pst" if [ ! -e $DEB_PROVIDES ] then wget -q http://apt.puppetlabs.com/$DEB sudo dpkg -i $DEB fi sudo apt-get update sudo apt-get install -o Dpkg::Options:: = "--force-confold" --force-yes -y puppet else echo "Puppet is up to date!" fi
Further processing, the user needs to create a manifest file inside Manifests directory with the name site.pp which will install some software on VM.
node brclelocal03.brcl.com { package { [ vim , git ] : ensure => latest } } echo "Running puppet" sudo puppet apply /etc/puppet/manifests/site.pp
Once the user has the above script ready with the required Vagrant file configuration, the user can cd to the test directory and run the vagrant up command. This will boot a new VM, Later, install Puppet and then run it using the Shell script.
Following will be the output.
Notice: Compiled catalog for localdev.example.com in environment production in 0.09 seconds Notice: /Stage[main]/Main/Node[brclelocal03.brcl.com]/Package[git]/ensure: created Notice: /Stage[main]/Main/Node[brcllocal03.brcl.com]/Package[vim]/ensure: ensure changed purged to latest
Vapdating Multiple Machine Configuration
If we need to test the configuration of multiple machines locally, it can be simply done by making a change in Vagrant configuration file.
New Configured Vagrant File
config.vm.define "brclelocal003" do |brclelocal003| brclelocal03.vm.hostname = "brclelocal003.brcl.com" end config.vm.define "production" do |production| production.vm.hostname = "brcleprod004.brcl.com" end
Let’s assume we have a new production server, which needs SSL utipty installed. We just need to extend the old manifest with the following configuration.
node brcleprod004.brcl.com inherits brcleloacl003.brcl.com { package { [ SSL ] : ensure => latest } }
After making configurational changes in the manifest file, we just need to move to the test directory and run the basic vagrant up command which will bring up both brclelocal003.brcl.com and brcleprod004.brcl.com machine. In our case, we are trying to bring up production machine which could be done by running the vagrant up production command. The will create a new machine with the name production as defined in Vagrant file and it will have SSL package installed in it.
Advertisements