Skip to content

Building Puppet

aborkar-ibm edited this page Dec 8, 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.6, 7.7, 7.8) has 3.6.2
  • Ubuntu 18.04 has 5.4.0
  • Ubuntu 20.04 has 5.5.10

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

  • RHEL (7.6, 7.7, 7.8, 8.1, 8.2)
  • Ubuntu (18.04, 20.04)
  • SLES (15 SP1, 15 SP2)

Open source Puppet is made up of puppet-agent and puppetserver. Latest Puppet version, 6.18.0, includes Puppet Server version 6.13.0 and puppet-agent version 6.18.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.18.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: Build Puppet Server

2.1) Install the following dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL (7.6, 7.7, 7.8, 8.1, 8.2)

    sudo yum install -y gcc-c++ readline-devel gawk tar unzip libyaml-devel PackageKit-cron openssl-devel make git wget sqlite-devel glibc-common hostname zip ant
  • 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
  • Ubuntu 20.04

    sudo apt-get update
    sudo apt-get install -y g++ tar make git wget libsqlite3-dev libc6-dev cron locales locales-all unzip libyaml-dev zlibc zlib1g-dev zlib1g libxml2-dev libgdbm-dev libffi7 ruby ruby-dev ant zip
  • SLES (15 SP1, 15 SP2)

    sudo zypper install -y wget tar make gcc-c++ gawk openssl-devel zlib-devel git ant zip unzip hostname gzip

2.2) Download and install Ruby

  • RHEL, SLES
    cd $SOURCE_ROOT
    wget https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.gz
    tar -xzf ruby-2.7.1.tar.gz
    cd ruby-2.7.1
    ./configure && make && sudo -E env PATH="$PATH" make install

2.3) Install bundler

sudo -E env PATH="$PATH" gem install bundler rake-compiler

2.4) Build jffi

Build jffi using OpenJDK 8

cd $SOURCE_ROOT
wget -O openjdk8.tar.gz "https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u265-b01_openj9-0.21.0/OpenJDK8U-jdk_s390x_linux_openj9_8u265b01_openj9-0.21.0.tar.gz"
mkdir openjdk8
tar -zxvf openjdk8.tar.gz -C openjdk8/ --strip-components 1
wget https://github.com/jnr/jffi/archive/jffi-1.2.23.tar.gz
tar -xzf jffi-1.2.23.tar.gz
cd jffi-jffi-1.2.23
JAVA_HOME="${SOURCE_ROOT}/openjdk8" PATH="${SOURCE_ROOT}/openjdk8/bin:${PATH}" 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) Install OpenJDK 11

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

cd $SOURCE_ROOT
wget -O openjdk11.tar.gz "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.8_10.tar.gz"
mkdir openjdk11
tar -zxvf openjdk11.tar.gz -C openjdk11/ --strip-components 1
export JAVA_HOME="${SOURCE_ROOT}/openjdk11"
export PATH="${JAVA_HOME}/bin:${PATH}"

2.7) Clone puppetserver Git repository

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

2.8) Set up Config Files

  • Run dev-setup

    export LANG="en_US.UTF-8" # RHEL 7.x, RHEL 8.1, SLES and Ubuntu
    ./dev-setup

    dev-setup may fail with NotImplementedError. Ignore this error.

    Apply the following fix and re-run the script.

    cp $SOURCE_ROOT/jffi-jffi-1.2.23/build/native.jar ~/.m2/repository/com/github/jnr/jffi/1.2.23/jffi-1.2.23-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.13.0/jruby-stdlib-9.2.13.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.13.0/jruby-stdlib-9.2.13.0.jar

2.9) Test Puppet Server (Optional)

cd $SOURCE_ROOT/puppetserver
 RUBYOPT='-W0' PUPPETSERVER_HEAP_SIZE=6G lein test  # to run the clojure test suite

Note: This command uses a heap size of 6GB. Please ensure that adequate system memory is available. See https://puppet.com/docs/puppet/6.18/server/dev_running_from_source.html#running-tests for more information about running the tests.

All tests should pass.

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 Puppet Server

Start puppet server using the development configuration file.

cd $SOURCE_ROOT/puppetserver
RUBYOPT='-W0' lein run -c dev/puppetserver.conf

See https://puppet.com/docs/puppet/6.18/server/configuration.html for more information about configuration options.

Note: You can set the autosign option to true (puppet config set autosign true) to allow the server to sign incoming certificates for testing purposes. This option should not be set to true in production environments. See https://puppet.com/docs/puppet/6.18/configuration.html#autosign for more details.

Step 3: Install Puppet Agent

3.1) Install the following dependencies

  • RHEL (7.6, 7.7, 7.8, 8.1, 8.2)

    sudo yum install -y gcc-c++ tar openssl-devel make wget gawk hostname
  • Ubuntu 18.04

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

    sudo apt-get update
    sudo apt-get install -y g++ tar make wget ruby ruby-dev libffi7
  • SLES

    sudo zypper install -y gcc-c++ tar openssl-devel zlib-devel make wget gawk hostname gzip

3.2) Download and install Ruby

  • RHEL, SLES
    cd $SOURCE_ROOT
    wget https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.gz
    tar -xzf ruby-2.7.1.tar.gz
    cd ruby-2.7.1
    ./configure && make && sudo -E env PATH="$PATH" make install

3.3) Install Puppet Agent

sudo -E env PATH="$PATH" gem install bundler rake-compiler
sudo -E env PATH="$PATH" gem install facter -v 2.5.7
sudo -E env PATH="$PATH" gem install puppet -v 6.18.0

3.4) Configure Puppet Agent

In order to connect Puppet agent to the server it may be necessary to configure Puppet agent. For example, you may need to set the server hostname to connect to. It may also be necessary to generate and sign a certificate for the Puppet agent. See https://puppet.com/docs/puppet/6.18/install_agents.html#configure_server_setting for instructions for how to do this.

If you are running both the server and agent on the same host for testing you may be able to skip this step. The server and agent should use the same certificate automatically.

3.5) Run Puppet Agent

The following command will run Puppet agent in test mode using the default configuration file. This test requires a Puppet server to connect to.

puppet agent -t

References:

Clone this wiki locally