Skip to content

Building Puppet

aborkar-ibm edited this page Mar 30, 2020 · 71 revisions

Building Puppet

Below versions of Puppet are available in respective distributions at the time of creation of these build instructions:

  • RHEL (7.5, 7.6, 7.7) has 3.6.2
  • Ubuntu 16.04 has 3.8.5
  • Ubuntu 18.04 has 5.4.0

The instructions provided below specify the steps to build Puppet 6.13.0 on Linux on IBM Z for the following distributions

  • RHEL (7.5, 7.6, 7.7)
  • Ubuntu (16.04, 18.04)

Open source Puppet is made up of puppet-agent and puppetserver. Latest Puppet version, 6.13.0, includes Puppet Server version 6.9.0 and puppet-agent version 6.13.0. For details, see Puppet packages and versions.

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.

  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Step 1: Build using script

If you want to build Puppet using manual steps, go to STEP 2.

Use the following commands to build Puppet using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/Puppet/6.13.0/build_puppet.sh

# Build Puppet
bash build_puppet.sh -s [server/agent]

If the build completes successfully for server installation, continue to STEP 2.8 and update puppet.conf. For agent installation, go to STEP 3.7. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

Step 2: Run Puppet Server

2.1) Install the following dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL (7.5, 7.6, 7.7)

    sudo yum install -y gcc-c++ readline-devel tar openssl unzip libyaml-devel PackageKit-cron openssl-devel make git wget sqlite-devel glibc-common hostname zip ant
  • Ubuntu (16.04)

    sudo apt-get update
    sudo apt-get install -y wget zip unzip tar git g++ make rake libreadline6 libreadline6-dev openssl libyaml-dev libssl-dev libsqlite3-dev libc6-dev cron locales locales-all ant zip
  • Ubuntu (18.04)

    sudo apt-get update
    sudo apt-get install -y g++ libreadline7 libreadline-dev tar make git wget libsqlite3-dev libc6-dev cron locales locales-all unzip libyaml-dev zlibc zlib1g-dev zlib1g libxml2-dev libgdbm-dev openssl1.0 libssl1.0-dev ruby ruby-dev ant zip

2.2) Download and install Ruby

  • RHEL (7.5, 7.6, 7.7) and Ubuntu 16.04
    cd $SOURCE_ROOT
    wget https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.0.tar.gz
    tar -xzf ruby-2.7.0.tar.gz
    cd ruby-2.7.0
    ./configure && make && sudo -E make install

2.3) Install bundler

  • RHEL (7.5, 7.6, 7.7), Ubuntu 16.04

    cd $SOURCE_ROOT
    sudo /usr/local/bin/gem install bundler rake-compiler
  • Ubuntu 18.04

    cd $SOURCE_ROOT
    sudo /usr/bin/gem install bundler rake-compiler

2.4) Build jffi (requires Java 8)

cd $SOURCE_ROOT
wget https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08/OpenJDK8U-jdk_s390x_linux_hotspot_8u242b08.tar.gz
tar zxf OpenJDK8U-jdk_s390x_linux_hotspot_8u242b08.tar.gz
export JAVA_HOME=$SOURCE_ROOT/jdk8u242-b08
export PATH=$JAVA_HOME/bin:$PATH

cd $SOURCE_ROOT
wget https://github.com/jnr/jffi/archive/jffi-1.2.19.tar.gz
tar -xzf jffi-1.2.19.tar.gz
cd jffi-jffi-1.2.19
ant jar

2.5) Install lein

cd $SOURCE_ROOT
wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
chmod +x lein && sudo mv lein /usr/bin/

2.6) Download and use OpenJDK 11

Note: Use OpenJDK 11 to run puppetserver as runtime crash will occur with OpenJDK 8

cd $SOURCE_ROOT
wget https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.6%2B10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.6_10.tar.gz
tar xzf OpenJDK11U-jdk_s390x_linux_hotspot_11.0.6_10.tar.gz
export JAVA_HOME=$SOURCE_ROOT/jdk-11.0.6+10
export PATH=$JAVA_HOME/bin:$PATH

2.7) Clone puppetserver Git repository

cd $SOURCE_ROOT
git clone --recursive --branch 6.9.0 git://github.com/puppetlabs/puppetserver
cd puppetserver

2.8) Set up Config Files

  • Run dev-setup

    export LANG="en_US.UTF-8"
    ./dev-setup

    dev-setup will fail with NotImplementedError. This is due to missing native support in jffi and can be fixed by replacing the jffi jar and re-running ./dev-setup as mentioned below:

    cp $SOURCE_ROOT/jffi-jffi-1.2.19/build/native.jar ~/.m2/repository/com/github/jnr/jffi/1.2.19/jffi-1.2.19-native.jar
    rm ~/.puppetlabs/opt/server/data/puppetserver/vendored-jruby-gems/cache/*.gem  # remove any invalid gems
    ./dev-setup
  • Update jruby-stdlib

    cd $SOURCE_ROOT
    unzip -q ~/.m2/repository/org/jruby/jruby-stdlib/9.2.8.0/jruby-stdlib-9.2.8.0.jar
    cp META-INF/jruby.home/lib/ruby/stdlib/ffi/platform/powerpc-aix/*.rb META-INF/jruby.home/lib/ruby/stdlib/ffi/platform/s390x-linux/
    cp META-INF/jruby.home/lib/ruby/stdlib/ffi/platform/powerpc-aix/platform.conf META-INF/jruby.home/lib/ruby/stdlib/ffi/platform/s390x-linux/
    zip -qr jruby-stdlib.jar META-INF
    cp jruby-stdlib.jar ~/.m2/repository/org/jruby/jruby-stdlib/9.2.8.0/jruby-stdlib-9.2.8.0.jar
  • Define config home directory $confdir

    Note: The default Puppet configuration directory is ~/.puppetlabs/etc/puppet. It is defined in $SOURCE_ROOT/puppetserver/dev/puppetserver.conf.

    export confdir=~/.puppetlabs/etc/puppet
    echo $confdir

    If such directory does not exist, create one.

    mkdir -p $confdir
  • Create necessary directories and files in $confdir

    mkdir $confdir/modules
    mkdir $confdir/manifests
    cd $confdir
    touch puppet.conf
    wget https://raw.githubusercontent.com/puppetlabs/puppet/master/conf/auth.conf
    mkdir -p $confdir/opt/puppetlabs/puppet
    mkdir -p $confdir/var/log

2.9) Update puppet.conf

Update $confdir/puppet.conf file with the following options (assuming hostname of the server machine is server.myhost.com)

Note: Hostname can found by running the command hostname -f

[main]
logdir = $confdir/var/log/puppetlabs
basemodulepath = $confdir/modules
server = server.myhost.com
pluginsync = false

[master]
certname = server.myhost.com
autosign = true

2.10) Firewall configuration

The Puppet server runs on TCP port 8140. This port needs to be open on your server firewall (and any intervening firewalls and network devices), and your agent must be able to route and connect to the server.

2.11) Run puppetserver

  • Start puppetserver
    cd $SOURCE_ROOT/puppetserver
    lein run -c dev/puppetserver.conf

2.12) Test puppetserver (Optional)

cd $SOURCE_ROOT/puppetserver
lein test  # to run the clojure test suite
rake spec  # to run the jruby test suite

Note: There may be a few failures, which are also observed on x86_64 platform. Set export JVM_ARGS="-Xms1024m -Xmx1024m" if you are experiencing OutOfMemoryError while running the test cases.

Step 3: Install Puppet Agent

3.1) Install the following dependencies

  • RHEL (7.5, 7.6, 7.7)

    sudo yum install -y gcc-c++ tar openssl openssl-devel make wget glibc-common hostname
  • Ubuntu (16.04)

    sudo apt-get update
    sudo apt-get install -y g++ tar make wget openssl libssl-dev
  • Ubuntu (18.04)

    sudo apt-get update
    sudo apt-get install -y g++ tar make wget openssl1.0 libssl1.0-dev ruby ruby-dev

3.2) Download and install Ruby

  • RHEL (7.5, 7.6, 7.7) and Ubuntu 16.04
    cd $SOURCE_ROOT
    wget https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.0.tar.gz
    tar -xzf ruby-2.7.0.tar.gz
    cd ruby-2.7.0
    ./configure && make && sudo -E make install

3.3) Install bundler

  • RHEL (7.5, 7.6, 7.7) and Ubuntu (16.04)

    cd $SOURCE_ROOT
    sudo /usr/local/bin/gem install bundler rake-compiler
  • Ubuntu 18.04

    cd $SOURCE_ROOT
    sudo /usr/bin/gem install bundler rake-compiler

3.4) Install Puppet

  • RHEL (7.5, 7.6, 7.7) and Ubuntu 16.04

    cd $SOURCE_ROOT
    sudo /usr/local/bin/gem install facter -v 2.5.7
    sudo /usr/local/bin/gem install puppet -v 6.13.0
  • Ubuntu (18.04)

    cd $SOURCE_ROOT
    sudo /usr/bin/gem install facter -v 2.5.7
    sudo /usr/bin/gem install puppet -v 6.13.0

3.5) Locate $confdir by command

Note: Please make sure the directory /usr/local/lib has sufficient read and execute permissions to run the above command. In case it doesn't, run sudo chmod 755 /usr/local/lib to give the necessary permissions. Make sure that /usr/local/bin is available in PATH environment variable.

export confdir=`puppet agent --configprint confdir`
echo $confdir

The output gives the directory. If such directory does not exist, create one.

mkdir -p $confdir

3.6) Create necessary directories and files in $confdir

cd $confdir
mkdir -p $confdir/opt/puppetlabs/puppet
mkdir -p $confdir/var/log
touch puppet.conf

3.7) Update $confdir/puppet.conf

Update $confdir/puppet.conf file with the following options (assuming hostname of the server machine is server.myhost.com and hostname of the agent machine is agent.myhost.com)

Note: Hostname can found by running the command hostname -f

[main]
logdir = $confdir/var/log
basemodulepath = /etc/puppetlabs/puppet/modules
server = server.myhost.com
pluginsync = false

[agent]
certname = agent.myhost.com
report = true
pluginsync = false

3.8) Add an entry in /etc/hosts file with IP address and hostname of server node

sudo vi /etc/hosts
<server ipaddress> <server hostname>

Step 4: Connecting the server and agent for the first time

4.1) Run the Puppet server application on the server node

cd $SOURCE_ROOT/puppetserver
rm -rf ~/.puppetlabs/etc/puppet/ssl # optional
lein run -c dev/puppetserver.conf

4.2) Run the agent application (assuming the hostname of the agent is agent.myhost.com)

sudo rm -rf /etc/puppetlabs/puppet/ssl
puppet agent -t --debug

References:

Clone this wiki locally