Puppet 101: PuppetServer
Published in
2 min readJun 21, 2018
In my last blog post, I explained how to install and configure a puppet agent, in this blog post I am going to install and configure a Puppetserver. It will help us as a provisioner orchestrator, this means that it will be responsible for providing the resource definition of what we want to install in a node where the puppet agent was installed previously.
Development environment:
- Ubuntu 18.04 LTS
- Tmux
- Visual Studio Code and the puppet extension
- VirtualBox
- Vagrant
Recommendations:
- ruby version manager RVM
- ruby version 2.3.3
Let's spin up a vagrant box with centos 7 and Puppetserver installed.
puppetserver.sh
#!/usr/bin/env bash# This bootstraps Puppet on CentOS 7.xset -e# (Optional) remove manually placed repo file/bin/rm -f /etc/yum.repos.d/puppetlabs*REPO_URL="http://yum.puppetlabs.com/puppet5/puppet5-release-el-7.noarch.rpm"if [ "$EUID" -ne "0" ]; thenecho "######## This script must be run as root. ########" >&2exit 1fiif which puppet > /dev/null 2>&1; thenecho "######## Puppet is already installed. ########"exit 0fi# Install wgetecho "######## Installing wget... ########"yum install -y wget > /dev/null# Install puppet labs repoecho "######## Configuring PuppetLabs repo... ########"repo_path=$(mktemp)wget --output-document="${repo_path}" "${REPO_URL}" 2>/dev/nullrpm -i "${repo_path}" >/dev/null# Install Puppet...echo "######## Installing puppet && Start puppet services ########"yum install -y puppetserver > /dev/nullruby_version=2.3.0echo "######## Installing Ruby ########"gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3\curl -sSL https://raw.githubusercontent.com/wayneeseguin/rvm/stable/binscripts/rvm-installer | sudo bash -s stable --ruby=${ruby_version} > /dev/nullsource /usr/local/rvm/scripts/rvmsed -i 's/-Xms2g/-Xms256m/g' /etc/sysconfig/puppetserversed -i 's/-Xmx2g/-Xmx256m/g' /etc/sysconfig/puppetserversystemctl start puppetserversystemctl start puppetecho "######## Puppet installed! ########"
Vagrantfile
# -*- mode: ruby -*-# vi: set ft=ruby :Vagrant.configure(2) do |config|config.vm.box = 'puppetserver101'config.vm.box = "bento/centos-7.5"config.vm.hostname = 'master.vagrant.local'config.vm.network 'private_network', ip: '172.31.0.201'config.vm.synced_folder '../', '/vagrant', :mount_options => ['dmode=775', 'fmode=644']config.vm.provider 'virtualbox' do |vb|vb.memory = '2048'endconfig.vm.provision 'shell', inline: <<-SHELLecho '######## Adding `sudo su` to the `.bashrc` for `vagrant` user ########'echo 'sudo su' >> /home/vagrant/.bashrcecho '######## Puppet Server Scripts ########'bash /vagrant/puppetserver/scripts/puppetserver.shSHELLend
Check if the puppetserver and the puppet service are running: