Official Salt docs on installing Salt on Solaris are quite out of date so this article is meant to illustrate how you can install SaltStack minion package on Solaris 10 (x86 and SPARC) hosts. Just like the official docs, we will be using OpenCSW but Salt itself will be installed using PIP. We will need to install the following application stacks and their dependencies:

  • pkgutil
  • python2.7
  • py_pyzmq
  • py_m2crypto
  • py_crypto
  • py_pip
  • salt

Start off by installing the OpenCSW's pkgutil application:

sudo pkgadd -d http://get.opencsw.org/now

Make sure that your /etc/opt/csw/pkgutil.conf has mirror= set to an unstable repository.

Install python2.7 and pip from OpenCSW:

sudo /opt/csw/bin/pkgutil -i -y python27
sudo /opt/csw/bin/pkgutil -i -y py_pip
sudo /opt/csw/bin/pkgutil -i -y py_pyzmq
sudo /opt/csw/bin/pkgutil -i -y py_m2crypto
sudo /opt/csw/bin/pkgutil -i -y py_crypto

Install Salt using PIP:

sudo /opt/csw/bin/pip install salt

Salt is now installed. You can verify its version using:

/opt/csw/bin/salt-minion --versions-report
Salt: 2015.5.1
Python: 2.7.8 (default, Sep 23 2014, 12:13:35)
Jinja2: 2.7.3
M2Crypto: 0.21.1
msgpack-python: 0.4.6
msgpack-pure: Not Installed
pycrypto: 2.6.1
libnacl: Not Installed
PyYAML: 3.11
ioflo: Not Installed
PyZMQ: 2.2.0.1
RAET: Not Installed
ZMQ: 2.2.0
Mako: Not Installed

Like any other daemon on a unix system, we will want to be able to launch and stop it easily. This is where SMF (Service Management Facility) comes into play. Start off by adding salt-minion.xml and/or salt-master.xml manifest file. On Solaris, SMF manifest files basically define how a service should be stopped, started, and restarted. You can use the files below:

salt-minion.xml:

<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<!--
Service manifest for salt-minion
Autogenerated by CSWinitsmf
2008-04-21 Peter Bonivart
-->

<service_bundle type='manifest' name='salt-minion:salt-minion'>

<service
  name='network/salt-minion'
  type='service'
  version='1'>
  <create_default_instance enabled='false' />
  <single_instance />

  <dependency name='fs'
    grouping='require_all'
    restart_on='none'
    type='service'>
    <service_fmri value='svc:/system/filesystem/local' />
  </dependency>

  <dependency name='net'
    grouping='require_all'
    restart_on='none'
    type='service'>
    <service_fmri value='svc:/network/loopback' />
  </dependency>

  <exec_method
    type='method'
    name='start'
    exec='/lib/svc/method/svc-salt-minion start'
    timeout_seconds='120'>
  </exec_method>

  <exec_method
    type='method'
    name='stop'
    exec='/lib/svc/method/svc-salt-minion stop'
    timeout_seconds='60'>
  </exec_method>

  <exec_method
    type='method'
    name='restart'
    exec='/lib/svc/method/svc-salt-minion restart'
    timeout_seconds='180'>
  </exec_method>

</service>

</service_bundle>

Those files will go into /var/svc/manifest/system directory. Make sure to set the correct permissions:

sudo chown root:sys /var/svc/manifest/system/salt-{minion,master}.xml
sudo chmod 444 /var/svc/manifest/system/salt-{minion,master}.xml

Import the manifest files:

sudo svccfg validate /var/svc/manifest/system/salt-minion.xml
sudo svccfg validate /var/svc/manifest/system/salt-master.xml
sudo svccfg import /var/svc/manifest/system/salt-minion.xml
sudo svccfg import /var/svc/manifest/system/salt-master.xml

Create a method file for salt. Method files are basically like rc scripts. Manifest files instructs us to call these method files to perform daemon functions accordingly.

svc-salt-minion:

#!/bin/sh
#
#AUTOENABLE no
#

PATH=/opt/csw/bin:$PATH
export PATH
CONF_DIR=/etc/salt
PIDFILE=/var/run/salt-minion.pid
SALTMINION=/opt/csw/bin/salt-minion

[ ! -d ${CONF_DIR} ] &&  exit $CONF_DIR

start_service() {
        /bin/rm -f ${PIDFILE}
        $SALTMINION -d -c ${CONF_DIR} 2>&1
}

stop_service() {
        if [ -f "$PIDFILE" ]; then
                /usr/bin/kill -TERM `/usr/bin/cat $PIDFILE`
        fi
}

case "$1" in
start)
        start_service
        ;;
stop)
        stop_service
        ;;
restart)
        stop_service
        sleep 1
        start_service
        ;;
*)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
        ;;
esac

You can substitute salt-minion for salt-master if you like and call this file svc-salt-minion or svc-salt-master depending on what you plan on doing. Copy this file to /lib/svc/method/.

sudo cp svc-salt-minion /lib/svc/method/

Before you attempt starting salt-minion, make sure that /etc/salt exists and contains a valid /etc/salt/minion and /etc/salt/minion_id files.

Start the salt-minion service:

sudo svcadm enable salt-minion

You can verify that salt-minion started by doing:

svcs -xv grep salt-minion

You should see this:

svc:/network/salt-minion:default (?)
State: online since June 2, 2015 2:14:02 PM CDT
See: /var/svc/log/network-salt-minion:default.log
Impact: None.

If you salt-minion service in maintenance state, look at the log. If the log says something along the lines of:

[ERROR ] Could not cache minion ID: [Errno 2] No such file or directory: '/opt/local/etc/salt/minion_id'

Make sure that your /opt/csw/lib/python2.7/site-packages/salt/_syspaths.py file is populated as such:

ROOT_DIR = '/'
CONFIG_DIR = '/etc/salt'
CACHE_DIR = '/var/cache/salt'
SOCK_DIR = '/var/run/salt'
SRV_ROOT_DIR = '/srv'
BASE_FILE_ROOTS_DIR = '/srv/salt'
BASE_PILLAR_ROOTS_DIR = '/srv/pillar'
BASE_MASTER_ROOTS_DIR = '/srv/salt-master'
LOGS_DIR = '/var/log/salt'
PIDFILE_DIR = '/var/run'

Comments

comments powered by Disqus