Saltstack install: Difference between revisions

From wikinotes
 
(8 intermediate revisions by the same user not shown)
Line 6: Line 6:
how you'd like to use salt.
how you'd like to use salt.


* '''salt-master/salt-minion:'''  
* '''salt-master/salt-minion:'''
** salt-master: hosted on central server. keeps the statefiles, pillar, and manages encryption/decryption of pillar.
** salt-master: hosted on central server. keeps the statefiles, pillar, and manages encryption/decryption of pillar.
** salt-minion: hosted on each salt-managed server. Receives/Applies instructions from salt-master.
** salt-minion: hosted on each salt-managed server. Receives/Applies instructions from salt-master.
Line 15: Line 15:
== Installer Options ==
== Installer Options ==
<blockquote>
<blockquote>
If you are installing on a unix system, you can install salt either by using the version of  
If you are installing on a unix system, you can install salt either by using the version of
salt in your distrobution's package repository ''or'' using salt's bootstrap script.
salt in your distrobution's package repository ''or'' using salt's bootstrap script.


Line 32: Line 32:
= platforms =
= platforms =
<blockquote>
<blockquote>
== Virtualenv ==
<blockquote>
{{ NOTE |
virtualenv could be used on it's own, but salt also has requirements on the python version that is used.
It is safest to use pyenv to handle this requirement. }}
Saltstack is written in python, an interpreted language.<br>
Most package managers do not isolate installed programs, leading to requirement conflicts.<br>
There is value in installing saltstack into a virtualenv, so that your userland and saltstack do not conflict with each other.<br>
Downsides include taking responsibility for updates. Please make certain to do so!
=== Base Install ===
<blockquote>
{{ NOTE |
Check '''classifiers''' to determine latest supported python version<br>
https://github.com/saltstack/salt/blob/master/setup.py
}}
<syntaxhighlight lang="bash">
sudo -i
pacman -S python-pyenv        # use your dist's pkg manager
virtualenv services/saltstack
cd services/saltstack
bin/pip install salt
</syntaxhighlight>
</blockquote><!-- Base Install -->
=== systemd ===
<blockquote>
<syntaxhighlight lang="systemd">
# /etc/systemd/system/virtualenv-salt-minion.service
[Unit]
Description=Salt-Minion
[Service]
KillMode=process
Type=notify
NotifyAccess=all
LimitNOFILE=8192
ExecStart=/root/services/saltstack/bin/salt-minion
[Install]
WantedBy=multi-user.target
</syntaxhighlight>
You'll also want to install symlinks for salt's various executables.
<syntaxhighlight lang="bash">
for exe in salt-api salt salt-api salt-call salt-cloud salt-cp salt-key salt-run salt-ssh salt-syncdic salt-unity; do
    ln -s /root/services/saltstack/bin/${exe} /usr/bin/${exe}
done
</syntaxhighlight>
</blockquote><!-- systemd -->
=== FreeBSD-init ===
<blockquote>
TODO
</blockquote><!-- FreeBSD-init -->
</blockquote><!-- Virtualenv -->
== FreeBSD ==
== FreeBSD ==
<source lang="bash">
<source lang="bash">
Line 103: Line 44:
<source lang="bash">
<source lang="bash">
sudo pacman -S salt
sudo pacman -S salt
</source>
== Ubuntu/Debian ==
<source lang="bash">
</source>
== CentOS ==
<source lang="bash">


systemctl enable salt-master@service  # runs as user 'salt'
systemctl enable salt-minion@service  # runs as user 'root'
</source>
</source>


== Windows ==
== Windows ==
<source lang="yaml">
<source lang="yaml">
Diable UAC
Diable UAC
</source>
</source>


Manual Install (best)
<syntaxhighlight lang="bash">
https://docs.saltproject.io/salt/install-guide/en/latest/topics/install-by-operating-system/windows.html#install-windows
</syntaxhighlight>
Choco Install (lags)
<source lang="powershell">
<source lang="powershell">
choco install saltminion
choco install saltminion
Line 141: Line 80:
</source>
</source>


== custom systemd ==
<blockquote>
<syntaxhighlight lang="systemd">
# /etc/systemd/system/virtualenv-salt-minion.service
[Unit]
Description=Salt-Minion
[Service]
KillMode=process
Type=notify
NotifyAccess=all
LimitNOFILE=8192
ExecStart=/root/services/saltstack/venv/bin/salt-minion
[Install]
WantedBy=multi-user.target
</syntaxhighlight>
You'll also want to install symlinks for salt's various executables.
<syntaxhighlight lang="bash">
for exe in salt-api salt salt-api salt-call salt-cloud salt-cp salt-key salt-run salt-ssh salt-syncdic salt-unity; do
    (test -e /usr/bin/${exe} || test -L /usr/bin/${exe}) && sudo rm -rf /usr/bin/${exe}
    sudo ln -s /root/services/saltstack/venv/bin/${exe} /usr/bin/${exe}
done
</syntaxhighlight>
Finally, enable
<syntaxhighlight lang="bash">
systemctl --system daemon-reload
systemctl enable virtualenv-salt-minion.service
</syntaxhighlight>
</blockquote><!-- custom systemd -->
== Virtualenv ==
<blockquote>
{{ WARNING |
this was a bad idea. it fixed my python/pip issues, but all file.managed states broke due to decoding issues even despite the salt/python versions matching.
}}
{{ NOTE |
virtualenv could be used on it's own, but salt also has requirements on the python version that is used.
It is safest to use pyenv to handle this requirement. }}
Saltstack is written in python, an interpreted language.<br>
Most package managers do not isolate installed programs, leading to requirement conflicts.<br>
There is value in installing saltstack into a virtualenv, so that your userland and saltstack do not conflict with each other.<br>
Downsides include taking responsibility for updates. Please make certain to do so!
=== Base Install ===
<blockquote>
{{ NOTE |
Check '''classifiers''' to determine latest supported python version<br>
https://github.com/saltstack/salt/blob/master/setup.py
}}
{{ NOTE |
It would be sensible to create a repo of pipenv managed services,
then you could install the same one across multiple OS's
}}
<syntaxhighlight lang="bash">
pacman -S python-pipenv                # use your dist's pkg manager
sudo mkdir -p /root/services/saltstack
</syntaxhighlight>
<syntaxhighlight lang="dosini">
# /root/servics/saltstack/Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
virtualenv = "*"
[dev-packages]
[requires]
python_version = "3.9"
</syntaxhighlight>
<syntaxhighlight lang="bash">
pipenv install
pipenv run virtualenv venv
venv/bin/pip install salt
</syntaxhighlight>
</blockquote><!-- Virtualenv -->
</blockquote><!-- Base Install -->
</blockquote><!-- platforms -->
</blockquote><!-- platforms -->

Latest revision as of 18:36, 27 August 2023

General

Installation Type

Salt has very flexible installation options. Before you install, you should decide how you'd like to use salt.

  • salt-master/salt-minion:
    • salt-master: hosted on central server. keeps the statefiles, pillar, and manages encryption/decryption of pillar.
    • salt-minion: hosted on each salt-managed server. Receives/Applies instructions from salt-master.
  • serverless
    • states/pillar stored locally, and states are applied with argument --local.

Installer Options

If you are installing on a unix system, you can install salt either by using the version of salt in your distrobution's package repository or using salt's bootstrap script.

Bootstrap script Install

curl -L https://bootstrap.saltstack.com -o /tmp/install_salt.sh
sudo sh /tmp/install_salt.sh -M
rm      /tmp/install_salt.sh

platforms

FreeBSD

pkg instsall py37-salt

# if unable to master over localhost, likely a silent permissions issue
find /var/log/salt -exec chown salt:salt {} \;
find /usr/local/etc/salt -exec chown salt:salt {} \;

Archlinux

sudo pacman -S salt

systemctl enable salt-master@service  # runs as user 'salt'
systemctl enable salt-minion@service  # runs as user 'root'

Windows

Diable UAC

Manual Install (best)

https://docs.saltproject.io/salt/install-guide/en/latest/topics/install-by-operating-system/windows.html#install-windows

Choco Install (lags)

choco install saltminion

MacOS

macports

sudo port install salt-minion
sudo port install py27-crypto
sudo port install py27-requests

# enable service
sudo port load salt-minion

brew

brew install saltstack

custom systemd

# /etc/systemd/system/virtualenv-salt-minion.service

[Unit]
Description=Salt-Minion

[Service]
KillMode=process
Type=notify
NotifyAccess=all
LimitNOFILE=8192
ExecStart=/root/services/saltstack/venv/bin/salt-minion

[Install]
WantedBy=multi-user.target

You'll also want to install symlinks for salt's various executables.

for exe in salt-api salt salt-api salt-call salt-cloud salt-cp salt-key salt-run salt-ssh salt-syncdic salt-unity; do
    (test -e /usr/bin/${exe} || test -L /usr/bin/${exe}) && sudo rm -rf /usr/bin/${exe}
    sudo ln -s /root/services/saltstack/venv/bin/${exe} /usr/bin/${exe}
done

Finally, enable

systemctl --system daemon-reload
systemctl enable virtualenv-salt-minion.service

Virtualenv

WARNING:

this was a bad idea. it fixed my python/pip issues, but all file.managed states broke due to decoding issues even despite the salt/python versions matching.

NOTE:

virtualenv could be used on it's own, but salt also has requirements on the python version that is used. It is safest to use pyenv to handle this requirement.

Saltstack is written in python, an interpreted language.
Most package managers do not isolate installed programs, leading to requirement conflicts.
There is value in installing saltstack into a virtualenv, so that your userland and saltstack do not conflict with each other.
Downsides include taking responsibility for updates. Please make certain to do so!

Base Install

NOTE:

Check classifiers to determine latest supported python version
https://github.com/saltstack/salt/blob/master/setup.py

NOTE:

It would be sensible to create a repo of pipenv managed services, then you could install the same one across multiple OS's

pacman -S python-pipenv                 # use your dist's pkg manager
sudo mkdir -p /root/services/saltstack
# /root/servics/saltstack/Pipfile

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
virtualenv = "*"

[dev-packages]

[requires]
python_version = "3.9"
pipenv install
pipenv run virtualenv venv
venv/bin/pip install salt