This repo provides a Salt setup with one master and one (or multiple) minions to be able to test and work with states, pillars and all other salt functionality. By using docker it's easy to reproduce and test you code.
Image includes both salt-master, salt-minion, salt-api and also salt-cloud to be able to test and troubleshoot all things salt. SALT_USE
environment variable is used to determent if container should be running as master or minion.
Salt master is auto accepting all minions.
Run one container with a master/minion setup.
docker run -it --name=saltdocker_master_1 -h master -p 4505 -p 4506 \
-p 8080 -p 8081 -e SALT_NAME=master -e SALT_USE=master \
-v `pwd`/srv/salt:/srv/salt:rw -v /etc/localtime:/etc/localtime jacksoncage/salt
By jumping in with docker exec -i -t saltdocker_master_1 bash
your able to test/troubleshoot. Now your ready to write you states and test them out.
Using docker machine and composer to get a multi-minion setup. Copy and configure docker-compose.yml.example
to docker-compose.yml
and run the following
brew install docker-machine docker-compose
docker-machine create --driver virtualbox salt
eval "$(docker-machine env salt)"
docker-compose up
By jumping in with docker exec -i -t saltdocker_master_1 bash
your able to test/troubleshoot. Now your ready to write you states and test them out.
Env variables are used to set config on startup, you can set the following envs
SALT_USE
- master/minion, defaults to masterSALT_NAME
- minion name, defaults to to masterSALT_GRAINS
- set minion grains as json, defaults to noneLOG_LEVEL
- log level, defaults to infoOPTIONS
- other options passed into salt process, defaults to none
Following paths can be mounted from the container. /srv/salt
is needed to run your local states.
/etc/salt
- Master/Minion config/var/cache/salt
- job data cache/var/logs/salt
- logs/srv/salt
- states, pillar reactors
The pre built image can be downloaded using docker directly. After that you do not need to use this command again, you will have the image on your local computer.
docker pull jacksoncage/salt
If you prefer you can easily build the docker image by yourself. After this the image is ready for use on your machine and can be used for multiple starts.
git clone git@github.com:jacksoncage/salt-docker.git
cd salt-docker
docker build -t jacksoncage/salt .