Building SaltStack - linux-on-ibm-z/docs GitHub Wiki

Building SaltStack

Below versions of SaltStack(Salt) are available in respective distributions at the time of creation of these build instructions:

  • RHEL (9.2, 9.3, 9.4) have 3005.4
  • SLES 15 SP5 has 3006.0
  • Ubuntu 22.04 has 3004.1

The instructions provided below specify the steps to build SaltStack(Salt) v3007.1 on Linux on IBM Z for the following distributions:

  • RHEL (8.8, 8.9, 8.10, 9.2, 9.3, 9.4)
  • SLES (12 SP5, 15 SP5)
  • Ubuntu (20.04, 22.04, 24.04)

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 Salt using manual steps, go to STEP 2.

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

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/SaltStack/3007.1/build_salt.sh

# Build Salt
bash build_salt.sh   [Provide -t for executing build with tests]

If the build completes successfully, go to STEP 5 to configure salt. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

Step 2: Install the dependencies

export SOURCE_ROOT=/<source_root>/
export PATCH_URL="https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/SaltStack/3007.1/patch/"
  • RHEL (8.8, 8.9, 8.10)

    sudo yum install -y procps-ng zeromq-devel cyrus-sasl-devel gcc gcc-c++ git libffi-devel libtool libxml2-devel libxslt-devel make man swig tar wget cmake bzip2-devel gdbm-devel libdb-devel libnsl2-devel libuuid-devel ncurses-devel openssl openssl-devel readline-devel sqlite-devel tk-devel xz xz-devel zlib-devel glibc-langpack-en diffutils bzip2-devel sqlite-devel
    
  • RHEL (9.2, 9.3, 9.4)

    sudo yum install -y procps-ng zeromq-devel cyrus-sasl-devel gcc gcc-c++ git libffi-devel libtool libxml2-devel libxslt-devel make man openssl-devel swig tar wget cmake python3-devel python3-pip bzip2-devel sqlite-devel
    
  • SLES 12 SP5

    sudo zypper install -y curl cyrus-sasl-devel gawk gcc gcc-c++ git libopenssl-devel libxml2-devel libxslt-devel make man tar wget cmake libnghttp2-devel gdbm-devel libbz2-devel libdb-4_8-devel libffi48-devel libuuid-devel ncurses-devel readline-devel sqlite3-devel tk-devel xz-devel zlib-devel gzip bzip2 libbz2-devel 
    
    • Install Openssl
    cd $SOURCE_ROOT
    wget https://www.openssl.org/source/openssl-1.1.1q.tar.gz --no-check-certificate
    tar -xzf openssl-1.1.1q.tar.gz
    cd openssl-1.1.1q
    ./config --prefix=/usr/local --openssldir=/usr/local
    make
    sudo make install
    sudo ldconfig /usr/local/lib64
    
    export PATH=/usr/local/bin:$PATH
    export LDFLAGS="-L/usr/local/lib/ -L/usr/local/lib64/"
    export LD_LIBRARY_PATH="/usr/local/lib/:/usr/local/lib64/"
    export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
    export CPPFLAGS="-I/usr/local/include/ -I/usr/local/include/openssl"
    
  • SLES 15 SP5

    sudo zypper install -y curl cyrus-sasl-devel gawk gcc gcc-c++ git libopenssl-devel libxml2-devel libxslt-devel make man tar wget cmake libnghttp2-devel gdbm-devel libbz2-devel libdb-4_8-devel libffi-devel libuuid-devel ncurses-devel readline-devel sqlite3-devel tk-devel xz-devel zlib-devel gzip bzip2 libbz2-devel
    
  • Ubuntu 20.04

    sudo apt-get update
    sudo apt-get install -y wget g++ gcc git libffi-dev libsasl2-dev libssl-dev libxml2-dev libxslt1-dev libzmq3-dev make man python3-dev python3-pip tar libz-dev pkg-config apt-utils curl cmake libbz2-dev libsqlite3-dev 
    
  • Ubuntu (22.04, 24.04)

    sudo apt-get update
    sudo apt-get install -y wget g++ gcc git libffi-dev libsasl2-dev libssl-dev libxml2-dev libxslt1-dev libzmq3-dev make man tar wget libz-dev pkg-config apt-utils curl cmake libbz2-dev libdb-dev libgdbm-dev liblzma-dev libncurses-dev libreadline-dev libsqlite3-dev tk-dev uuid-dev xz-utils zlib1g-dev libbz2-dev libsqlite3-dev 
    

2.1) Install Python and required dependencies

  • Install Python 3.10.12

    cd $SOURCE_ROOT
    wget https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tgz
    tar -xzf Python-3.10.12.tgz
    cd Python-3.10.12
    ./configure --prefix=/usr/local --exec-prefix=/usr/local --enable-loadable-sqlite-extensions
    make
    sudo make install
    export PATH=/usr/local/bin/python3.10:$PATH
    python3 -V
    
  • Install M2Crypto (RHEL only)

    pip3 install M2Crypto
    
  • Install Rust

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
    source $HOME/.cargo/env
    rustup default 1.78.0
    
  • Install Libgit2

    cd $SOURCE_ROOT
    wget https://github.com/libgit2/libgit2/archive/refs/tags/v1.7.0.tar.gz 
    tar xzf v1.7.0.tar.gz
    cd libgit2-1.7.0/
    cmake .
    make
    sudo make install
    
  • Install Python packages-

    pip3 install pyzmq 'PyYAML<5.1' pycrypto msgpack-python jinja2 psutil futures tornado python-dateutil genshi         #For RHEL and SLES Only 
    pip3 install pyzmq 'PyYAML<5.1' pycrypto msgpack-python jinja2 psutil futures==2.2.0 tornado python-dateutil genshi  #For Ubuntu Only   
    

Step 3: Build and install

Clone the repository and install SaltStack

cd $SOURCE_ROOT
git clone --depth 1 -b v3007.1 https://github.com/saltstack/salt.git
cd salt
curl -sSL $PATCH_URL/salt.patch |  git apply -
pip3 install -e .

Step 4: Test SaltStack (Optional)

cd $SOURCE_ROOT/salt
pip3 install nox
CFLAGS="-std=c99" python3 -m nox -e "test-3(coverage=False)" -- --core-tests --slow-tests        #Only for SLES 12.5
python3 -m nox -e "test-3(coverage=False)" -- --core-tests --slow-tests                          #On all other distros

Note: There are around 40 test failures observed on all distros on Intel and Z.

Step 5: Configure SaltStack to run self-contained version

  • Edit $SOURCE_ROOT/salt/master and $SOURCE_ROOT/salt/minion:
currentuser="$(whoami)"
sed -i "s/#user: root/user: $currentuser/" conf/master
sed -i 's,#root_dir: /,'"root_dir: $SOURCE_ROOT"',' conf/master
sed -i 's/#publish_port: 4505/publish_port: 4505/' conf/master
sed -i 's/#ret_port: 4506/ret_port: 4506/' conf/master
sed -i 's/#master: salt/master: localhost/' conf/minion
sed -i "s/#user: root/user: $currentuser/" conf/minion
sed -i 's,#root_dir: /,'"root_dir: $SOURCE_ROOT"',' conf/minion
sed -i 's/#master_port: 4506/master_port: 4506/' conf/minion
sed -i 's/#id:/id: saltdev/' conf/minion

Note: If the ret_port value in the master config file is changed, set the same value to master_port value in the minion config file

  • Now you can start your Salt master and minion, specifying the config dir.:
    salt-master --config-dir=$SOURCE_ROOT/salt/conf --log-level=debug --daemon
    salt-minion --config-dir=$SOURCE_ROOT/salt/conf --log-level=debug --daemon
    

Note: If above command throws error salt-master: command not found then set PATH as export PATH=$SOURCE_ROOT/.local/bin:$PATH install -y salt-master salt-minion salt-ssh salt-syndic salt-cloud salt-api

  • Now you should be able to accept the minion key:
    salt-key -c $SOURCE_ROOT/salt/conf -Ay
    
  • Check that your master/minion are communicating:
    salt -c $SOURCE_ROOT/salt/conf \* test.version
    

References: