Giter Site home page Giter Site logo

salinity's Introduction

Salinity

Test your Salt formula on a Docker container

Requirements

  • A docker host
  • Python 2.7

Limitations

Currently Salinity only supports running your formula on a Debian 7 environment.

Install

$ sudo pip install salinity

Getting started

Salinity let you run a salt formula located on your local computer in a virtual salt environment.

This quick example will show you how to use Salinity to test the official mysql formula.

Clone the official mysql formula

$ git clone https://github.com/saltstack-formulas/mysql-formula.git

Create a pillar test file for salinity

$ cd mysql-formula
$ vim test.sls

Enter the following pillar data :

mysql:
    server:
        root_user: 'admin'
        root_password: 'somepass'
        user: mysql

lookup:
    server: mysql-server
    service: mysql

Test the mysql.server state with salinity

$ salinity test --pillar_file=test.sls mysql.server
[...]
----------
      ID: mysqld
Function: service.running
    Name: mysql
  Result: True
 Comment: Service mysql is already enabled, and is running
 Started: 19:54:41.498938
Duration: 3372.095 ms
 Changes:
          ----------
          mysql:
              True

Summary
------------
Succeeded: 6 (changed=4)
Failed:    0
------------
Total states run:     6
root@d7764b152842:/#

Salinity will start a docker container running salt master and salt minion to test the mysql.server state. Once the state has been applied on the container, Salinity stay in the container waiting for instruction.

You can either quit the container (Ctrl + D) or relaunch your state if you would like to check some modification in your formula :

# salt-call state.highstate

Clean up

# exit

If you leave the container, Salinity will delete any temporary files and return to your host shell

Usage

The Salinity utility is handling commands in the form

$ salinity [OPTIONS] COMMAND [ARGS]

Currently, the only command available is the test command.

test command

The test command let you test one or more states of your formula on a virtual salt environment.

$ salinity test [ARGS] [STATES]

--image

Name of the docker image used to run salt.

Available images are :

  • debian7-salt2015.8 alias debian7
  • debian8-salt2015.8 alias debian8
  • debian8-salt2016.11 alias debian8-latest
  • debian9-salt2016.11 alias debian9-latest
  • debian-latest which is latest version of both debian and salt (so debian9-salt2016.11 here)

Default is debian-latest

--formula_dir

Path to the directory containing your salt formula. If not specified, Salinity will use current directory.

--pillar_file

Pillar file to use when applying the state

--gitfs_formula

Git repositories URL that should be made available on the salt master running your formula. Theses formulas are generally dependencies of the formula your are testing.

The option can be used several times.

Each URL should have one of the following form :

--pubkey

Path to the public key to use when accessing gitfs formulas through ssh.

--privkey

Path to the private key to use when accessing gitfs formulas through ssh.

Currently RSA keys protected by a passphrase are not supported.

--use_default_keys

Not functional : future release

Tell Salinity to use your default RSA keys (~/.ssh/id_rsa.pub and ~/.ssh/id_rsa).

Currently RSA keys protected by a passphrase are not supported.

Using Salinity configuration file

Salinity can read options from a standard configuration file called salinity.yml. This file should be located in the directory from which Salinity is called.

Options passed to the command line have priority on the options read from the configuration file.

Here is a example of a salinity.yml file

image: debian-latest
pillar_file: pillar.test.sls
gitfs_formula:
    - https://github.com/saltstack-formulas/mysql-formula.git
    - https://github.com/saltstack-formulas/nginx-formula.git
pubkey: ~/.ssh/salinity_rsa.pub
privkey: ~/.ssh/salinity_rsa

Building Docker images

Note : Salinity uses Docker images hosted on docker hub.

To build and distribute a Docker image for Salinity, here are the common commands :

docker build -t igbmc/salinity:debian7-salt2015.8 -t igbmc/salinity:debian7 docker_builds/debian7
docker push igbmc/salinity:debian7
docker push igbmc/salinity:debian7-salt2015.8

salinity's People

Contributors

julozi avatar tmadmac avatar

Stargazers

Alexey Zudenkov avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

julozi

salinity's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.