Salt State Development
Most orchestration tools are unsympathetic to the process of iterating on both the development and the deployment fronts. They tend to either make the process opaque, if not impossible, on how to work with a disposable development VM or container, which given their mission statements I find somewhat ironic.
Below is the process I use with a client.
We assume that your git/svn/whatever Salt State project lives at:
You can use any VM, but lets show a
docker example as it can be shown on the CLI:
docker pull ubuntu docker run -it --rm -v /usr/src/salt-states:/srv/salt-states ubuntu /bin/bash
ubuntu as it comes with an
init that makes the next section Just Work(tm)
Now run inside the container:
If you require a full
init, then use instead:
docker run --rm -d --privileged -v /usr/src/salt-states:/srv/salt-states ubuntu /sbin/init 012345 docker exec -it 012345 /bin/bash
As above, run
debian_install_salt_minion.sh inside the container.
Now you can edit the state file you are working on in your regular project tree, and just iterate using:
salt-call -l info state.apply STATE
STATE with the name of whichever state file you are working on.
These are the files you need to have present in your
#!/bin/sh set -eu . /etc/os-release apt-get update apt-get install --no-install-recommends -y wget ca-certificates wget -O - https://repo.saltstack.com/apt/$ID/$VERSION_ID/amd64/latest/SALTSTACK-GPG-KEY.pub | apt-key add - cat <<EOF > /etc/apt/sources.list.d/saltstack.list deb http://repo.saltstack.com/apt/$ID/$VERSION_ID/amd64/latest $VERSION_CODENAME main EOF apt-get update apt-get install --no-install-recommends -y salt-ssh # https://docs.saltstack.com/en/latest/topics/tutorials/quickstart.html cat <<'EOF' > /etc/salt/minion master_type: disable file_client: local EOF mkdir -p /etc/salt/minion.d ln -s /srv/salt-states/etc/salt/minion /etc/salt/minion.d/salt-states.conf exit 0
file_roots: base: - /srv/salt-states pillar_roots: base: - /srv/salt-states/etc/salt/pillar