Skip to content

intuitivetechnologygroup/saltstack-meetup-2018-03-13

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

SaltStack Meetup Demo (3/13/2018)

The Problem

I started developing a new salt formula and I need to test it...

  • in an isolated environment.
  • in a ci/cd tool such as travis.
  • run a series of pytests.
  • run an interactive test sandbox

A Solution

There are many ways to solve this problem. This demo will cover the formula-test-harness option. This test harness utilizes allsalt to spin up salt master/minion containers.

Example Formula

This demo is using a trimmed down version of the gpg-formula.

Run through a manual test

Run this command to start a test container:

docker run --rm -d -v $(pwd):/opt -v $(pwd)/gpg:/srv/salt/gpg -h salt-master-sandbox --name salt-master-sandbox simplyadrian/allsalt:centos_master_2017.7.2

Let's shell into the container and verify our state is in place:

docker exec -it salt-master-sandbox bash

# ensure the state is in the right place
ls /srv/salt/gpg

Now we can run the state and verify a key was generated:

# run the state
salt-call -l debug state.apply gpg

# verify the key was generated
salt-call gpg.list_keys gnupghome='/etc/salt/gpgkeys'

Exit the shell and kill the container

docker kill salt-master-sandbox

Implement the Test Harness

  1. Fork this repository
  2. Follow the install instructions in the formula-test-harness docs
  3. Start a virtualenv and run the setup:
pip install -U virtualenv
virtualenv .venv
source .venv/bin/activate
make setup
  1. Run the centos test:
make test-centos_master_2017.7.2

Run tests in Travis

  • go to travis-ci.org and create an account if you don't have one
  • on the left side of the screen click on the + next to My Repositories
  • search for saltstack-meetup (if it does not show up try syncing your account and search again)
  • click on the gray toggle thing next to the repository name
  • commit and push the changes to your fork
  • view the test status here: https://travis-ci.org/YOUR-GITHUB-USERNAME/saltstack-meetup-2018-03-13

DOJO

Dig into it...

  • write another test
  • your ideas?

About

Demo for the SaltStack Meetup on 3/13/2018

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published