Skip to content

SaltStack formulas presetup/install/testing/usage

Look through docs briefly

Official Doc (not so great, but useful)

Installation

Prepare Salt formulas

Fork what you want from salt formulas.

Why? Because official documentation points to it, but also unconditionally requires.

Create a branch in formulas

Correspond to your environment ('base' in my setup):

1
2
3
4
git clone formula
git cd formula
git checkout -b 'base'
git push origin 'base'

Install Git Backend in Python

Need to use deprecated Dulwich on Arch. preferred pygit2 is installed, but was not working on Arch.

Officail notes: installing-dependencies.

In Arch Linux:

1
yaourt -Syu python2-dulwich

Or use PIP install:

1
pip install pygit2
1
pip install gitpython
1
pip install dulwich

Enable Salt to use GIT backend

1
2
3
4
5
/etc/salt/master
---
fileserver_backend:
  - git
  - roots
These list going to be searched through in listed order.

More at: section on fileserver backends.

Enable formula remote repos

1
2
3
4
/etc/salt/master
---
gitfs_remotes:
  - https://github.com/saltstack-formulas/docker-formula.git
Reference information:

  1. You add that as remote repository of formulas. official doc

  2. This is basically works as literal remote fs. official doc

Official documentation has an error

Bug

Be sure to put '.git' at the end of GIT URLs. Salt requires them to parse links with python backends.

Formulas usage

To use formulas:

in sls file

1
2
3
*.sls
---
  - docker
or
1
2
3
*.sls
---
docker:

to install formula using docker-formula.

Look at GitHub documentation of formulas to see how to do install with it and other actions. Name of formula does not required to correspond to install command. Like here.

To overload formula:

You can extend formulas or use their source. To include formula source in sls (you can overload, like docker.sls)

1
2
3
4
docker.sls
---
include:
  - docker
Here docker-formula source included in docker.sls, and add your commands, formulas and so on. That is called overload.

Testing

Check if SaltStack formula works

1
sudo salt 'host' state.show_sls docker

To debug Master

1
sudo salt-master -l debug

If you get: [CRITICAL] No suitable gitfs provider module is installed.

SaltStack can not find python git backend (pygit2, GitPython or Dulwich). So you need to figure-out this.

Look at Docker state module

https://docs.saltstack.com/en/latest/ref/states/all/salt.states.dockerng.html#module-salt.states.dockerng

Comments