Home

Awesome

buoyant

buoyant leverages docker to provide an alternative to VM-centric SaltStack development environments. buoyant containers may be spun up nearly instantly, once an initial docker image has been built.

A common docker pattern is to run few, or as little as a single process within a container. While buoyant containers run very few processes, they are very un-container-like, more resembling lightweight VMs as they run init and systemd. This configuration is necessary for the salt-minion to run, as well as for salt states such as service.running.

SaltStack development with buoyant containers is intended for use in developing states that will target full Linux instances, it is not intended for targeting states on production docker instances. Note that buoyant containers should never be run in production and should only exist in a trusted development environment. They require extended privileges (--privileged) for systemd to function.

Why Not Just Use Vagrant?

Vagrant is an excellent, mature, feature-rich tool that does work exceptionally well for SaltStack development.

What buoyant brings to the table is speed, simplicity, and instance management with the docker cli. Once a docker image has been created and is available, spinning up several test instances is nearly instantaneous, with zero configuration files to update. Common Vagrantfile options such as port forwarding and synced folders are handled with built-in Docker functionality. Instances can be treated as truly ephemeral and destroyed and created in a matter of seconds.

Pre-requisites

Getting Started

1) Clone this repository and cd to the top-level directory of the repository

2) Modify the Dockerfile

While buoyant works out of the box, it may be useful to change a few settings such as the version of salt to use.

3) Update files/resolv.conf

Update search domains and set nameservers.

4) Update files/sources.list

Update this file only when using a local Ubuntu mirror or using a different Ubuntu release.

5) Build a Reusable Base Image

docker build -t salt_minion_masterless:v15.10_2015.8.1 .

NOTE that we've included the Ubuntu and salt versions in the tag. A full image build process typically lasts as much as 10 minutes, but only has to be completed once.

6) Create web and redis instances

docker run -d --name web -h web.example.com  \
--privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v $(pwd)/srv/salt:/srv/salt \
-v $(pwd)/srv/pillar:/srv/pillar salt_minion_masterless:v15.10_2015.8.1 /sbin/init

docker run -d --name redis -h redis.example.com  \
--privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v $(pwd)/srv/salt:/srv/salt \
-v $(pwd)/srv/pillar:/srv/pillar salt_minion_masterless:v15.10_2015.8.1 /sbin/init

NOTE that --name is the short hostname. If the fqdn is used, the dots are replaced by hyphens in the /etc/hosts file. Ideally the hosts file would have both the short name and fqdn, but this does not appear to be possible with the automated host file management built into docker

6) Attach to the web and redis containers

docker exec -it web /bin/bash

docker exec -it redis /bin/bash

7) Run a highstate to install redis and nginx

root@web:/# salt-call state.highstate
root@redis:/# salt-call state.highstate

Basic example salt states are distributed with this repository

8) Test out pillar

root@web:/# salt-call pillar.item buoyant

9) Start writing states!

Development of states normally occurs under the home directory of the user present on the container host.

Container and Image Management

Please refer to the official Docker CLI documentation for information about working with images and containers.

Kill and delete the containers we created earlier

docker kill web redis && docker rm web redis

Delete the image we created earlier

docker rmi salt_minion_masterless:v15.10_2015.8.1

Tips

FAQ

Known Issues

License

Apache License, version 2.0. Please see LICENSE