Wednesday, April 5, 2017

Puppet Server 2.7.x + Puppet Agent 4.10.x + Foreman 1.15 on CentOS 7


This is really more for my notes after digging through all the various misconfigured puppet versions available. The documentation over on theforeman.org is really all that is required to bring up a puppet server 2.7.x + puppet agent 4.10 + Foreman 1.15 on CentOS 7.3.1611.

  1. Install CentOS Minimal: I provisioned the vm with 4G RAM/40G disk drive/4 core CPU
  2. Install the latest OS updates
    # yum -y update
  3. Install the puppet repository and its accompanying packages
    # yum -y install http://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
    # yum -y install puppetserver puppetdb
  4. Install the epel-release repository
    # yum -y install epel-release
  5. Install theforeman repository
    # yum -y install https://yum.theforeman.org/releases/latest/el7/x86_64/foreman-release.rpm
  6. Install theforeman's installer package
    # yum -y install foreman-installer
  7. Kick off the foreman installer and wait a few minutes -- it will "just work" when it's finished!
    # foreman-installer
    # puppet agent --test

A few notes on upgrading foreman! It's vastly easier to set a version number in
/etc/yum/tfmver, i.e. '1.15' and then reference that in the /etc/yum.repos.d/foreman.repo and foreman-plugins.repo, for example:

[foreman]
name=Foreman $tfmvers - $basearch
baseurl=http://yum.theforeman.org/releases/$tfmvers/el7/$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-foreman

[foreman-plugins]
name=Foreman plugins $tfmvers - $basearch
baseurl=http://yum.theforeman.org/plugins/$tfmvers/el7/$basearch
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-foreman


Thus, when upgrading, you can simply echo '1.15' > /etc/yum/tfmvers and then yum update.  It's also possible to use 'latest' or 'nightly' if you're diligent about your updates.


Upgrading Foreman
First select the version you'd like to upgrade to.  Foreman upgrades are linear, meaning that you must upgrade incrementally.  So, if you have 1.11 installed, and wish to move to 1.15, you'll need to go to 1.12 first, then from 1.12 to 1.13, then from 1.13 to 1.14, then finally from 1.14 to 1.15.  Sorry, those are the breaks - stay on top of your upgrades (at least monthly, approximately) and you can simply use 'latest' and never have to worry about it!
# echo '1.15' > /etc/yum/vars/tfmvers

-or-
# echo 'latest' > /etc/yum/vars/tfmvers

Clean the yum repository caches
# yum clean all


Stop the foreman, foreman-proxy and httpd services
# systemctl stop foreman foreman-proxy httpd


Trigger a foreman upgrade via yum
# yum upgrade tfm\* ruby\* foreman\* puppet\*


Run the migrate and seed rakes, then clear cache and sessions
# foreman-rake db:migrate
# foreman-rake db:seed
# foreman-rake tmp:cache:clear
# foreman-rake tmp:sessions:clear

Or for those of you who prefer one-liners..


# for i in db:migrate db:seed tmp:cache:clear tmp:sessions:clear; do foreman-rake $i; done

Restart your instance of foreman
# systemctl start foreman foreman-proxy httpd

That's really all there is to it -- happy provisioning!