Merge pull request #3 from martinhoefling/feature/travis-refactor

Feature/travis refactor
This commit is contained in:
Martin Hoefling 2015-05-15 23:26:16 +02:00
commit 577989ee3b
6 changed files with 70 additions and 1 deletions

35
.travis.yml Normal file
View File

@ -0,0 +1,35 @@
language: python
python:
- '2.7'
env:
global:
- BS_PIP_ALLOWED=1
- BS_ECHO_DEBUG=1
- SALT_ARGS="-l debug --local --retcode-passthrough --pillar-root=test/pillar --file-root=$PWD"
matrix:
- STATE=rsyncd
- STATE=rsyncd.config
before_install:
- sudo apt-get update
- curl -L http://bootstrap.saltstack.org | sudo -E sh -s -- stable
install:
- sudo mkdir -p /srv && sudo ln -sfn $PWD /srv/formula
# See what kind of travis box you're on to help with making your states
# compatible with travis
- sudo salt-call grains.items --local
script:
- sudo salt-call state.show_sls $STATE $SALT_ARGS
- sudo salt-call state.sls $STATE $SALT_ARGS
# For debugging purpose
- cat /etc/default/rsync
- test -f /etc/rsyncd.conf && cat /etc/rsyncd.conf || echo "No rsyncd.conf"
# Idempotence check
- sudo salt-call state.sls $STATE $SALT_ARGS > /tmp/second
- cat /tmp/second
- bash -c '! grep -q "^Not Run:" /tmp/second'

View File

@ -1,3 +1,6 @@
.. image:: https://travis-ci.org/martinhoefling/rsyncd-formula.svg?branch=master
:target: https://travis-ci.org/martinhoefling/rsyncd-formula
================ ================
rsyncd-formula rsyncd-formula
================ ================
@ -18,9 +21,18 @@ Available states
``rsyncd`` ``rsyncd``
------------ ------------
Installs the rsync package, and starts the rsyncd service. Installs the rsync package, and starts the rsyncd service. Note: The rsyncd.conf has to be created manually / via another state. If the state of the config should also be managed via salt, the rsyncd.config state (which pulls rsyncd) should be used instead.
``rsyncd.config`` ``rsyncd.config``
------------ ------------
Configure the rsync daemon by writing an rsync.conf and rsync secrets (optional). Configure the rsync daemon by writing an rsync.conf and rsync secrets (optional).
Testing
=======
As you can read in .travis.yml, testing is a matter of symlinking this
directory to /srv/formula (because we can't use relative paths in file_roots /
pillar_roots) and running::
salt-call state.show_highstate --local --retcode-passthrough --config-dir=test/etc

View File

@ -1,11 +1,23 @@
{% from "rsyncd/map.jinja" import rsyncd with context %} {% from "rsyncd/map.jinja" import rsyncd with context %}
rsyncd_conf_exists:
file.managed:
- name: {{ rsyncd.configfile }}
- contents: |
# This file is created by salt as a dummy, use the config state or override manually
pid file = /var/run/rsyncd.pid
use chroot = yes
read only = yes
- replace: false
rsync: rsync:
pkg.installed: pkg.installed:
- name: {{ rsyncd.pkg }} - name: {{ rsyncd.pkg }}
service.running: service.running:
- name: {{ rsyncd.service }} - name: {{ rsyncd.service }}
- enable: True - enable: True
- require:
- file: rsyncd_conf_exists
{% if grains.os_family == 'Debian' %} {% if grains.os_family == 'Debian' %}
/etc/default/rsync: /etc/default/rsync:

View File

@ -5,4 +5,10 @@
'configfile': '/etc/rsyncd.conf', 'configfile': '/etc/rsyncd.conf',
'secretsfile': '/etc/rsyncd.secrets' 'secretsfile': '/etc/rsyncd.secrets'
}, },
'Arch': {
'pkg': 'rsync',
'service': 'rsyncd',
'configfile': '/etc/rsyncd.conf',
'secretsfile': '/etc/rsyncd.secrets'
},
}, merge=salt['pillar.get']('rsyncd:lookup')) %} }, merge=salt['pillar.get']('rsyncd:lookup')) %}

1
test/pillar/example.sls Symbolic link
View File

@ -0,0 +1 @@
../../pillar.example

3
test/pillar/top.sls Normal file
View File

@ -0,0 +1,3 @@
base:
'*':
- example