├── .gitignore ├── Dockerfile ├── README.md └── run.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # OS 2 | *.DS_Store 3 | thumbs.db 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # Salt Stack Salt Master Container 3 | # 4 | 5 | FROM ubuntu:14.04 6 | MAINTAINER SOON_ 7 | 8 | # Update System 9 | RUN apt-get update && apt-get upgrade -y -o DPkg::Options::=--force-confold 10 | 11 | # Add PPA 12 | 13 | RUN apt-get install -y software-properties-common dmidecode 14 | RUN add-apt-repository -y ppa:saltstack/salt 15 | RUN apt-get update 16 | 17 | # Install Salt 18 | 19 | RUN apt-get install -y salt-master=2014.1.11+ds-2trusty1 20 | 21 | # Volumes 22 | 23 | VOLUME ['/etc/salt/pki', '/var/cache/salt', '/var/logs/salt', '/etc/salt/master.d', '/srv/salt'] 24 | 25 | # Add Run File 26 | 27 | ADD run.sh /usr/local/bin/run.sh 28 | RUN chmod +x /usr/local/bin/run.sh 29 | 30 | # Ports 31 | 32 | EXPOSE 4505 4506 33 | 34 | # Run Command 35 | 36 | CMD "/usr/local/bin/run.sh" 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker Salt-Master 2 | 3 | A Docker image which allows you to run a containerised Salt-Master server. 4 | 5 | ## Running the Container 6 | 7 | You can easily run the container like so: 8 | 9 | docker run --rm -it soon/salt-master 10 | 11 | ## Environment Variables 12 | 13 | The following environment variables can be set: 14 | 15 | * `LOG_LEVEL`: The level to log at, defaults to `error` 16 | 17 | ## Volumes 18 | 19 | There are several volumes which can be mounted to Docker data container as 20 | described here: https://docs.docker.com/userguide/dockervolumes/. The following 21 | volumes can be mounted: 22 | 23 | * `/etc/salt/pki` - This holds the Salt Minion authentication keys 24 | * `/var/cache/salt` - Job and Minion data cache 25 | * `/var/logs/salt` - Salts log directory 26 | * `/etc/salt/master.d` - Master configuration include directory 27 | * `/srv/salt` - Holds your states, pillars etc 28 | 29 | ### Data Container 30 | 31 | To create a data container you are going to want the thinnest possible docker 32 | image, simply run this docker command, which will download the simplest possible 33 | docker image: 34 | 35 | docker run -v /etc/salt/pki -v /var/salt/cache -v /var/logs/salt -v /etc/salt/master.d -v /srv/salt --name salt-master-data busybox true 36 | 37 | This will create a stopped container with the name of `salt-master-data` and 38 | will hold our persistant salt master data. Now we just need to run our master 39 | container with the `--volumes-from` command: 40 | 41 | docker run --rm -it --volumes-from salt-master-data soon/salt-master 42 | 43 | ### Sharing Local Folders 44 | 45 | To share folders on your local system so you can have your own master 46 | configuration, states, pillars etc just alter the `salt-master-data` 47 | command: 48 | 49 | docker run -v /etc/salt/pki -v /var/salt/cache -v /var/logs/salt -v /path/to/local:/etc/salt/master.d -v /path/to/local:/srv/salt --name salt-master-data busybox true 50 | 51 | Now `/path/to/local` can hold your states and master configuration. 52 | 53 | ## Ports 54 | 55 | The following ports are exposed: 56 | 57 | * `4505` 58 | * `4506` 59 | 60 | These ports allow minions to communicate with the Salt Master. 61 | 62 | ## Running Salt Commands 63 | 64 | You can run commands on the salt-master via the [`docker exec`](https://docs.docker.com/engine/reference/commandline/exec/) command. 65 | For one off commands, you can use: 66 | `docker exec salt-master-data salt "*" test.ping` 67 | or for an interactive shell use: 68 | `docker exec -it salt-master-data sh` 69 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Salt-Master Run Script 5 | # 6 | 7 | set -e 8 | 9 | # Log Level 10 | LOG_LEVEL=${LOG_LEVEL:-"error"} 11 | 12 | # Run Salt as a Deamon 13 | exec sudo /usr/bin/salt-master --log-level=$LOG_LEVEL 14 | --------------------------------------------------------------------------------