add kitchen ci
diff --git a/.gitignore b/.gitignore
index 6f76275..01c9905 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,7 @@
tests/build/
*.swp
-*.pyc
\ No newline at end of file
+*.pyc
+.venv/
+srv/
+.kitchen
+Gemfile.lock
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..5e6b195
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,75 @@
+---
+driver:
+ name: docker
+ #socket: tcp://127.0.0.1:2376
+ hostname: git.ci.local
+ use_sudo: true
+
+provisioner:
+ name: salt_solo
+ salt_install: bootstrap
+ salt_bootstrap_url: https://bootstrap.saltstack.com
+ salt_version: latest
+ require_chef: false
+ #init_environment: |
+ # # apt pkg required
+ # SALT_ROOT=${SALT_ROOT:-/tmp/kitchen/srv/salt}
+ # mkdir -p $SALT_ROOT;
+ # ln -fs /usr/share/salt-formulas/env/* $SALT_ROOT/
+ # # reclass required
+ # #mkdir -p $SALT_ROOT/reclass/classes
+ # #ln -fs /usr/share/salt-formulas/reclass/* $SALT_ROOT/reclass/
+ # #find $SALT_ROOT/git -name metadata -type d | xargs -I'{}' \
+ # # cp -fa {}/service $SALT_ROOT/reclass/classes/
+ vendor_repo:
+ - type: apt
+ url: http://apt.tcpcloud.eu/nightly
+ key_url: http://apt.tcpcloud.eu/public.gpg
+ components: main tcp-salt
+ dependencies:
+ - name: linux
+ repo: apt
+ package: salt-formula-linux
+ # Test of git external dependencies that are not directly required
+ - name: nginx
+ repo: git
+ source: https://github.com/tcpcloud/salt-formula-nginx.git
+ - name: postfix
+ repo: git
+ source: https://github.com/tcpcloud/salt-formula-postfix
+ #- name: salt
+ #repo: apt
+ #package: salt-formula-salt
+ log_level: error
+ formula: git
+ grains:
+ noservices: True
+ state_top:
+ base:
+ "*":
+ - git
+ pillars:
+ top.sls:
+ base:
+ "*":
+ - git
+verifier:
+ name: inspec
+ sudo: true
+
+
+platforms:
+ - name: ubuntu-14.04
+ - name: ubuntu-16.04
+ - name: centos-7.1
+
+
+suites:
+
+ - name: client_single
+ provisioner:
+ pillars-from-files:
+ git.sls: tests/pillar/client_single.sls
+
+
+# vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/INTEGRATION.rst b/INTEGRATION.rst
new file mode 100644
index 0000000..3a0d92f
--- /dev/null
+++ b/INTEGRATION.rst
@@ -0,0 +1,156 @@
+
+Continuous Integration
+======================
+
+Check your formulas locally before you create pull request.
+
+
+Usage
+------------------
+
+Update pillars in tests/pillar/\*.sls with test data.
+Executed tests with:
+
+.. code-block:: shell
+
+ kitchen list
+ kitchen test
+
+
+Test Kitchen
+------------------
+
+Use Travis/Jenkins to spin a kitchen instances in Docker or OpenStack environment.
+Default configuration is defined by ``.kitchen.yml`` and ``tests/pillar/*.sls``
+
+Override your specific needs with ``.kitchen.<backend|local>.yml`` that you may load as:
+``KITCHEN_LOCAL_YAML=.kitchen.<driver>.yml kitchen <action> <suite>``.
+
+Example: ``KITCHEN_LOCAL_YAML=.kitchen.local kitchen verify server-ubuntu-1404 -t tests/integration``.
+
+Base kitchen-test actions:
+
+1. *create*, provision an test instance (VM, container)
+2. *converge*, run a provisioner (shell script, kitchen-salt)
+3. *verify*, run a verification (inspec, other may be added)
+4. *destroy*
+
+
+Verifier
+~~~~~~~~
+
+The `Busser <https://github.com/test-kitchen/busser>`_ *Verifier* goes with test-kitchen by default.
+It is used to setup and run tests implemented in ``<repo>/test/integration``. It guess and installs the particular driver to tested instance.
+By default `InSpec <https://github.com/chef/kitchen-inspec>`_ is expected.
+
+You may avoid to install busser framework if you configure specific verifier in ``.kitchen.yml`` and install it kitchen plugin locally:
+
+ verifier:
+ name: serverspec
+
+If you would to write another verification scripts than InSpec store them in ``<repo>/tests/integration/<suite>/<busser>/*``.
+``Busser <https://github.com/test-kitchen/busser>`` is a test setup and execution framework under test kitchen.
+
+
+**InSpec**
+
+Implement integration tests under ``<repo>/tests/integration/<suite>/<busser>/*`` directory with ``_spec.rb`` filename
+suffix.
+
+Docs:
+
+* https://github.com/chef/inspec
+* https://github.com/chef/kitchen-inspec
+
+Requirements
+~~~~~~~~~~~~
+
+Use latest stable kitchen-salt and kitchen-test.
+Minimal supported version of kitchen-salt is >= v0.0.25.
+
+
+
+Jinja templates
+---------------
+To check jinja templates you may use:
+
+.. code-block:: shell
+
+ cat > check_my_jinja_recursive.py <<-EOF
+ import sys
+ import os
+ from jinja2 import Environment
+
+
+ def fileList(path, fileTypes):
+ matches = []
+ for root, dirnames, filenames in os.walk(path):
+ for filename in filenames:
+ if filename.endswith(fileTypes):
+ matches.append(os.path.join(root, filename))
+ return matches
+
+ env = Environment()
+ for path in sys.argv:
+ for template in fileList(path, ('.conf', '.ini', '.jinja2') ):
+ with open(template) as t:
+ print"Checking:", template
+ env.parse(t.read())
+ EOF
+
+
+Intstall Test Kitchen
+---------------------
+See http://kitchen.ci/ for more details.
+
+To install user side use:
+
+.. code-block:: shell
+
+ # install kitchen
+ gem install test-kitchen
+
+ # install additional plugins
+ gem install kitchen-docker kitchen-salt
+ gem install kitchen-vagrant kitchen-openstack kitchen-inspec busser-serverspec
+
+First you have to install ruby package manager `gem <https://rubygems.org/>`_.
+
+One may be satisfied installing it system-wide right from OS package manager which is preferred installation method.
+For advanced users or the sake of complex environments you may use `rbenv <https://github.com/rbenv/rbenv>`_ for user side ruby installation.
+
+ * https://github.com/rbenv/rbenv
+ * http://kitchen.ci/docs/getting-started/installing
+
+An example steps then might be:
+
+.. code-block:: shell
+
+ # get rbenv
+ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
+
+ # configure
+ cd ~/.rbenv && src/configure && make -C src # don't worry if it fails
+ echo 'export PATH="$HOME/.rbenv/bin:$PATH"'>> ~/.bash_profile
+ # Ubuntu Desktop note: Modify your ~/.bashrc instead of ~/.bash_profile.
+ cd ~/.rbenv; git fetch
+
+ # install ruby-build, which provides the rbenv install command
+ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
+
+ # list all available versions:
+ rbenv install -l
+
+ # install a Ruby version
+ # maybe you will need additional packages: libssl-dev, libreadline-dev, zlib1g-dev
+ rbenv install 2.0.0-p648
+
+ # activate
+ rbenv local 2.0.0-p648
+
+ # install test kitchen
+ gem install test-kitchen
+
+An optional ``Gemfile`` in the main directory may contain fine tuned dependencies for specific workflows.
+To install Gefmfile dependencies run ``gem install bundler`` and then run ``bundler install``.
+
diff --git a/README.rst b/README.rst
index e0c2227..bfe743a 100644
--- a/README.rst
+++ b/README.rst
@@ -44,3 +44,50 @@
* http://git-scm.com/
* http://git-scm.com/book/en/Customizing-Git-Git-Configuration
* https://github.com/nesi/puppet-git/tree/master/manifests
+
+Development and testing
+=======================
+
+Development and test workflow with `Test Kitchen <http://kitchen.ci>`_ and
+`kitchen-salt <https://github.com/simonmcc/kitchen-salt>`_ provisioner plugin.
+
+Test Kitchen is a test harness tool to execute your configured code on one or more platforms in isolation.
+There is a ``.kitchen.yml`` in main directory that defines *platforms* to be tested and *suites* to execute on them.
+
+Kitchen CI can spin instances locally or remote, based on used *driver*.
+For local development ``.kitchen.yml`` defines a `vagrant <https://github.com/test-kitchen/kitchen-vagrant>`_ or
+`docker <https://github.com/test-kitchen/kitchen-docker>`_ driver.
+
+To use backend drivers or implement your CI follow the section `INTEGRATION.rst#Continuous Integration`__.
+
+A listing of scenarios to be executed:
+
+.. code-block:: shell
+
+ $ kitchen list
+
+ Instance Driver Provisioner Verifier Transport Last Action
+
+ client-single-ubuntu-1404 Vagrant SaltSolo Inspec Ssh <Not Created>
+ client-single-ubuntu-1604 Vagrant SaltSolo Inspec Ssh <Not Created>
+ client-single-centos-71 Vagrant SaltSolo Inspec Ssh <Not Created>
+
+The `Busser <https://github.com/test-kitchen/busser>`_ *Verifier* is used to setup and run tests
+implementated in `<repo>/test/integration`. It installs the particular driver to tested instance
+(`Serverspec <https://github.com/neillturner/kitchen-verifier-serverspec>`_,
+`InSpec <https://github.com/chef/kitchen-inspec>`_, Shell, Bats, ...) prior the verification is executed.
+
+
+Usage:
+
+.. code-block:: shell
+
+ # list instances and status
+ kitchen list
+
+ # manually execute integration tests
+ kitchen [test || [create|converge|verify|exec|login|destroy|...]] [instance] -t tests/integration
+
+ # use with provided Makefile (ie: within CI pipeline)
+ make kitchen
+
diff --git a/tests/pillar/client_single.sls b/tests/pillar/client_single.sls
index b049fc4..44ee8d0 100644
--- a/tests/pillar/client_single.sls
+++ b/tests/pillar/client_single.sls
@@ -1,6 +1,18 @@
git:
client:
enabled: true
+ user:
+ - user:
+ name: jdoe
+ email: j@doe.com
linux:
system:
enabled: true
+ user:
+ jdoe:
+ enabled: true
+ sudo: true
+ full_name: John Doe
+ home: /home/jdoe
+ password:
+ passw0rd