SaltStack for Void Linux

From Void Linux Wiki
Jump to: navigation, search

According to Wikipedia-logo.png Wikipedia:

Salt (sometimes referred to as the SaltStack Platform) is a Python-based open-source configuration management software and remote execution engine. Supporting the "Infrastructure as Code" approach to deployment and cloud management, it competes primarily with puppet, chef, and ansible.

Overview

Starting with version 2015.8.3, SaltStack is available as an XBPS package for Void Linux. Since version 2016.11 SaltStack fully supports Void Linux as a target OS/distribution including the following:

  • Void Linux is a known Linux distribution,
  • XBPS is supported as a SaltStack (virtual) pkg manager,
  • XBPS is supported as a SaltStack package repository manager,
  • runit is fully supported as an init system,
  • sv is fully supported as a SaltStack (virtual) service management

The Void Linux distribution is characterized by the following Salt grains:

SaltStack grain Value on a Void Linux system
os Void
os_family Void
init runit

Salt minion on Void

Let's start by installing a SaltStack agent ("minion" in SaltStack terminology).

Installing salt

As usual:

[minion-void] sudo xbps-install -Su salt
[*] Updating `https://repo.voidlinux.eu/current/x86_64-repodata' ...

Name                  Action    Version           New version            Download size
libyaml               install   -                 0.1.7_1                - 
python-yaml           install   -                 3.12_2                 - 
python-MarkupSafe     install   -                 0.23_7                 - 
python-Jinja2         install   -                 2.8_2                  - 
python-chardet        install   -                 2.3.0_3                - 
python-six            install   -                 1.10.0_2               - 
python-urllib3        install   -                 1.19.1_1               - 
python-idna           install   -                 2.1_2                  - 
python-requests       install   -                 2.12.3_1               - 
libsodium             install   -                 1.0.11_1               - 
zeromq                install   -                 4.1.6_1                - 
python-pyzmq          install   -                 16.0.2_1               - 
python-crypto         install   -                 2.6.1_7                - 
python-typing         install   -                 3.5.2.2_3              - 
python-M2Crypto       install   -                 0.25.1_3               - 
python-singledispatch install   -                 3.4.0.3_1              - 
python-backports_abc  install   -                 0.5_1                  - 
python-tornado        install   -                 4.4.2_3                - 
python-msgpack        install   -                 0.4.8_3                - 
salt                  install   -                 2016.11.0_1            - 

Size required on disk:          32MB
Free space on disk:           3942MB

Do you want to continue? [Y/n] Y

Salt local grains and Void Linux

Once salt (minion) is installed, let's see what does SaltStack know about this host: list all local grains.

[minion-void] $ sudo salt-call --local -g

(The output is fine, it just shows relevant part to Void Linux support)

local:
    ----------
[...]
    cpu_flags:
        - fpu
        - vme
        - de
[...]
        - dtherm
        - arat
    cpu_model:
        Intel(R) Core(TM) i3 CPU       M 330  @ 2.13GHz
    cpuarch:
        x86_64
    disks:
        - loop1
        - loop6
        - loop4
  [...]
    host:
        oli73
    hwaddr_interfaces:
        ----------
        lo:
            00:00:00:00:00:00
        virbr0:
            52:54:00:b9:fb:f2
[...]
    id:
        oli73
    init:
        unknown
    ip4_interfaces:
        ----------
        lo:
            - 127.0.0.1
[...]
    kernel:
        Linux
    kernelrelease:
        4.8.11_1
[...]
    lsb_distrib_codename:
        void
    lsb_distrib_id:
        void
[...]
    os:
        Void
    os_family:
        Void
    osarch:
        x86_64
    oscodename:
        void
    osfullname:
        void
    osrelease:
    path:
        /usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
[...]
    saltpath:
        /usr/lib/python2.7/site-packages/salt
    saltversion:
        2016.11.0
    saltversioninfo:
        - 2016
        - 11
        - 0
        - 0
[...]

XBPS package listing

SaltStack is aware of XBPS packages installed on this salt minion too:

[minion-void] $ sudo salt-call --local pkg.list_pkgs
local:
    ----------
    CoinMP:
        1.8.3_3
    ConsoleKit2:
        1.1.0.1_1
    NetworkManager:
        1.0.12_8
    SDL:
        1.2.15_10
    acl:
        2.2.52_4
    acpid:
        2.0.28_1
    alsa-lib:
        1.1.2_1
    alsa-plugins-pulseaudio:
        1.1.1_2
[...]

Enabling salt-minion service

If you want the minion to automatically discuss with your SaltStack server, you will have to follow the next steps.

As usual with Salt, configure this minion (if needed for specific settings):

[minion-void] $ sudo vi /etc/salt/minion
...

Enable its service (sv will then launch it automatically):

[minion-void] $ sudo ln -s /etc/sv/salt-minion /var/service

Check:

[minion-void] $ sudo sv status salt-minion
run: salt-minion: (pid 721) 55611s

Do not forget to accept this new salt minion's key on the salt-master:

[salt-master] $ sudo salt-key -a <minion-void>

Salt management of Void Linux

On Salt server, let's manage a Void Linux based system.

Grains for Void Linux

Get some grains on a Void Linux system:

[salt-master] sudo salt 'minion-void' grains.items
minion-void:
    ----------
    lsb_distrib_id:
        void
[...]
    os:
        Void
    os_family:
        Void
    osarch:
        i686
    oscodename:
        void
    osfullname:
        void
    osrelease:
    path:
        /usr/bin:/usr/sbin
[...]

XBPS packages

Thanks to Salt's abstraction of package management (via pkg), XBPS packages can be manipulated the same way than other platforms.

Package listing

Retrieve version of package salt on all known (managed) Void Linux system:

[salt-master] $ sudo salt -G 'os:Void' pkg.version salt
minion-void:
    2015.8.3_1

Installing a package

To install the mtr package on all known (managed) Void Linux systems:

[salt-master] $ sudo salt -G 'os:Void' pkg.install mtr
minion-void:
    ----------
    mtr:
        ----------
        new:
            0.86_2
        old:

Service management

List sv services

To show info about the sshd service on all known (managed) Void Linux systems:

[salt-master] $ sudo salt -G 'os:Void' service.show sshd
void-minion:
    ----------
    autostart:
        True
    available:
        True
    command_path:
        /etc/sv/sshd/run
    disabled:
        True
    enabled:
        False
    running:
        False
    service_path:
        /etc/sv/sshd

Enable a service (sv)

To enable the sshd service on all known (managed) Void Linux systems:

[salt-master] $ sudo salt -G 'os:Void' service.enable sshd
void-minion:
    ----------
    True