From 5e5331c68a8398acb9073f1ef2b65f1ccfbc63fd Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 00:05:21 +0200 Subject: [PATCH 01/22] Enabled travis --- .travis.yml | 16 ++++++++++++++++ test/etc/minion | 7 +++++++ test/pillar/example.sls | 1 + test/pillar/top.sls | 3 +++ 4 files changed, 27 insertions(+) create mode 100644 .travis.yml create mode 100644 test/etc/minion create mode 120000 test/pillar/example.sls create mode 100644 test/pillar/top.sls diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ab01a9a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: python +python: + - '2.7' + +before_install: + - sudo apt-get update + - curl -L http://bootstrap.saltstack.org | sudo sh -s -- git develop + +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_highstate --local --retcode-passthrough --config-dir=test/etc diff --git a/test/etc/minion b/test/etc/minion new file mode 100644 index 0000000..85177ef --- /dev/null +++ b/test/etc/minion @@ -0,0 +1,7 @@ +file_roots: + base: + - /srv/formula + +pillar_roots: + base: + - /srv/formula/test/pillar diff --git a/test/pillar/example.sls b/test/pillar/example.sls new file mode 120000 index 0000000..837da91 --- /dev/null +++ b/test/pillar/example.sls @@ -0,0 +1 @@ +../../pillar.example \ No newline at end of file diff --git a/test/pillar/top.sls b/test/pillar/top.sls new file mode 100644 index 0000000..7bd0c36 --- /dev/null +++ b/test/pillar/top.sls @@ -0,0 +1,3 @@ +base: + '*': + - example From 5173b8cc5238a84addc67a6c3cfb6943d7188d32 Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 00:16:16 +0200 Subject: [PATCH 02/22] Added rsync state to travis --- test/etc/minion | 1 + test/salt/top.sls | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 test/salt/top.sls diff --git a/test/etc/minion b/test/etc/minion index 85177ef..a95a68b 100644 --- a/test/etc/minion +++ b/test/etc/minion @@ -1,5 +1,6 @@ file_roots: base: + - /srv/formula/test/salt - /srv/formula pillar_roots: diff --git a/test/salt/top.sls b/test/salt/top.sls new file mode 100644 index 0000000..77c38ab --- /dev/null +++ b/test/salt/top.sls @@ -0,0 +1,3 @@ +base: + '*': + - rsyncd From 89e974e3fcaeceaba4f958363867f934e17be97e Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 00:17:25 +0200 Subject: [PATCH 03/22] Document testing --- README.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.rst b/README.rst index acd1030..f225d86 100644 --- a/README.rst +++ b/README.rst @@ -24,3 +24,12 @@ Installs the rsync package, and starts the rsyncd service. ------------ 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 From f7e09107b03006fea8ad6bf69633e2c87c499c35 Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 00:22:16 +0200 Subject: [PATCH 04/22] Added Arch linux support --- rsyncd/map.jinja | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rsyncd/map.jinja b/rsyncd/map.jinja index d16bd9b..14e30ff 100644 --- a/rsyncd/map.jinja +++ b/rsyncd/map.jinja @@ -5,4 +5,10 @@ 'configfile': '/etc/rsyncd.conf', 'secretsfile': '/etc/rsyncd.secrets' }, + 'Arch': { + 'pkg': 'rsync', + 'service': 'rsyncd', + 'configfile': '/etc/rsyncd.conf', + 'secretsfile': '/etc/rsyncd.secrets' + }, }, merge=salt['pillar.get']('rsyncd:lookup')) %} From 52e24c5c2ee60fab4df35561295f13a3e004b90b Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 00:22:38 +0200 Subject: [PATCH 05/22] Also run highstate on travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ab01a9a..3457060 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,3 +14,4 @@ install: script: - sudo salt-call state.show_highstate --local --retcode-passthrough --config-dir=test/etc + - sudo salt-call state.highstate --local --retcode-passthrough --config-dir=test/etc From 08de91fc43792a5e4ebc8b204611818c3f8e9d04 Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 00:26:31 +0200 Subject: [PATCH 06/22] Try bootstrapping stable instead of develop --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3457060..29347d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ python: before_install: - sudo apt-get update - - curl -L http://bootstrap.saltstack.org | sudo sh -s -- git develop + - curl -L http://bootstrap.saltstack.org | sudo BS_PIP_ALLOWED=1 BS_ECHO_DEBUG=1 sh -s -- stable install: - sudo mkdir -p /srv && sudo ln -sfn $PWD /srv/formula From 2a63a06edb61feeec4514d4eb250253e18e5d449 Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 00:32:40 +0200 Subject: [PATCH 07/22] Cat some files for debugging It's currently failing because [ERROR ] Command ['service', 'rsync', 'start'] failed with return code: 1 [ERROR ] output: * Starting rsync daemon rsync * missing or empty config file /etc/rsyncd.conf ...fail! --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 29347d6..1a71fe6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,3 +15,5 @@ install: script: - sudo salt-call state.show_highstate --local --retcode-passthrough --config-dir=test/etc - sudo salt-call state.highstate --local --retcode-passthrough --config-dir=test/etc + - cat /etc/default/rsync + - cat /etc/rsyncd.conf From 6f1a6f9a0aabafe59ec7dcaa413e3e9a3d6ee1bf Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 00:34:31 +0200 Subject: [PATCH 08/22] Test including rsync.config instead of rsyncd --- test/salt/top.sls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/salt/top.sls b/test/salt/top.sls index 77c38ab..d9ade59 100644 --- a/test/salt/top.sls +++ b/test/salt/top.sls @@ -1,3 +1,3 @@ base: '*': - - rsyncd + - rsyncd.config From 2ca83d04dac1294de3573085d5ababba8b269bce Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 00:42:55 +0200 Subject: [PATCH 09/22] Move env variables and use sudo -E --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1a71fe6..18c295a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,14 @@ language: python python: - '2.7' +env: + global: + - BS_PIP_ALLOWED=1 + - BS_ECHO_DEBUG=1 + before_install: - sudo apt-get update - - curl -L http://bootstrap.saltstack.org | sudo BS_PIP_ALLOWED=1 BS_ECHO_DEBUG=1 sh -s -- stable + - curl -L http://bootstrap.saltstack.org | sudo -E sh -s -- stable install: - sudo mkdir -p /srv && sudo ln -sfn $PWD /srv/formula From 8e7aea65547735da4cc08a35955f3634f564f9bc Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 00:51:56 +0200 Subject: [PATCH 10/22] Attempt to make a test matrix --- .travis.yml | 7 +++++-- test/salt/top.sls | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 18c295a..3f064bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,9 @@ env: global: - BS_PIP_ALLOWED=1 - BS_ECHO_DEBUG=1 + matrix: + - STATE=rsyncd + - STATE=rsyncd.config before_install: - sudo apt-get update @@ -18,7 +21,7 @@ install: - sudo salt-call grains.items --local script: - - sudo salt-call state.show_highstate --local --retcode-passthrough --config-dir=test/etc - - sudo salt-call state.highstate --local --retcode-passthrough --config-dir=test/etc + - sudo salt-call state.show_sls $STATE --local --retcode-passthrough --config-dir=test/etc + - sudo salt-call state.sls $STATE --local --retcode-passthrough --config-dir=test/etc - cat /etc/default/rsync - cat /etc/rsyncd.conf diff --git a/test/salt/top.sls b/test/salt/top.sls index d9ade59..755c05c 100644 --- a/test/salt/top.sls +++ b/test/salt/top.sls @@ -1,3 +1,4 @@ base: '*': + - rsyncd - rsyncd.config From acac28b1f12befc1036243c73cbaa0811ae52cde Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 01:01:14 +0200 Subject: [PATCH 11/22] Added travis badge on README --- README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.rst b/README.rst index f225d86..30b3a04 100644 --- a/README.rst +++ b/README.rst @@ -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 ================ From d5a1dfab025fb8184ad82727e15e72d6ceb2c675 Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 01:18:02 +0200 Subject: [PATCH 12/22] Added idempotence check --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3f064bb..285b493 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,5 +23,7 @@ install: script: - sudo salt-call state.show_sls $STATE --local --retcode-passthrough --config-dir=test/etc - sudo salt-call state.sls $STATE --local --retcode-passthrough --config-dir=test/etc + # Idempotence check + - sudo salt-call state.sls $STATE --local --retcode-passthrough --config-dir=test/etc | grep '^Not Run:' && {echo 'Idempotence check failed'; exit 1} - cat /etc/default/rsync - cat /etc/rsyncd.conf From e62b524a2db363e4b6269109f607464bfbe125e9 Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 01:28:02 +0200 Subject: [PATCH 13/22] Cleanup .travis.yml and fixed syntax --- .travis.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 285b493..d5a2810 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,14 +16,19 @@ before_install: 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 + # 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 --local --retcode-passthrough --config-dir=test/etc - sudo salt-call state.sls $STATE --local --retcode-passthrough --config-dir=test/etc - # Idempotence check - - sudo salt-call state.sls $STATE --local --retcode-passthrough --config-dir=test/etc | grep '^Not Run:' && {echo 'Idempotence check failed'; exit 1} + + # For debugging purpose - cat /etc/default/rsync - cat /etc/rsyncd.conf + + # Idempotence check + - sudo salt-call state.sls $STATE --local --retcode-passthrough --config-dir=test/etc > /tmp/second + - grep '^Not Run:' /tmp/second && { echo 'Idempotence check failed'; exit 1; } || { echo 'Imdempotence passes'; exit 0; } + - cat /tmp/second From b20604d99b6b346d4f273e8e2228e4a5b40b9277 Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 01:40:48 +0200 Subject: [PATCH 14/22] Show /tmp/second before doing a check which exits --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d5a2810..13cedd7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,5 +30,5 @@ script: # Idempotence check - sudo salt-call state.sls $STATE --local --retcode-passthrough --config-dir=test/etc > /tmp/second - - grep '^Not Run:' /tmp/second && { echo 'Idempotence check failed'; exit 1; } || { echo 'Imdempotence passes'; exit 0; } - cat /tmp/second + - grep '^Not Run:' /tmp/second && { echo 'Idempotence check failed'; exit 1; } || { echo 'Imdempotence passes'; exit 0; } From dc09a0a65f9153e79b95b9394950539c2c673b0d Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 01:47:06 +0200 Subject: [PATCH 15/22] Idempotence check simplification. The previous version would report false-positives, ie.: https://travis-ci.org/martinhoefling/rsyncd-formula/jobs/62631447 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 13cedd7..a535665 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,4 +31,4 @@ script: # Idempotence check - sudo salt-call state.sls $STATE --local --retcode-passthrough --config-dir=test/etc > /tmp/second - cat /tmp/second - - grep '^Not Run:' /tmp/second && { echo 'Idempotence check failed'; exit 1; } || { echo 'Imdempotence passes'; exit 0; } + - ! grep -q '^Not Run:' /tmp/second From 0182c922a53fd9f12962185f68fceaefb8237d66 Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 01:57:03 +0200 Subject: [PATCH 16/22] Wrapping exclamation mark in a child bash call. It gets removed by travis otherwise: https://travis-ci.org/martinhoefling/rsyncd-formula/builds/62632850 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a535665..771f404 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,4 +31,4 @@ script: # Idempotence check - sudo salt-call state.sls $STATE --local --retcode-passthrough --config-dir=test/etc > /tmp/second - cat /tmp/second - - ! grep -q '^Not Run:' /tmp/second + - bash -c '! grep -q "^Not Run:" /tmp/second' From 49863f448ed1f38d042ab46ff783454b61c81640 Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 01:59:18 +0200 Subject: [PATCH 17/22] We don't want the test to fail for that ie. rsyncd state --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 771f404..1dbacf8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ script: # For debugging purpose - cat /etc/default/rsync - - cat /etc/rsyncd.conf + - test -f /etc/rsyncd.conf && cat /etc/rsyncd.conf || echo "No rsyncd.conf" # Idempotence check - sudo salt-call state.sls $STATE --local --retcode-passthrough --config-dir=test/etc > /tmp/second From a53085cb16cc185c71b9043e7ee77eb62bef6dd5 Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 02:16:14 +0200 Subject: [PATCH 18/22] Bypass salt/top.sls --- .travis.yml | 7 ++++--- test/salt/top.sls | 4 ---- 2 files changed, 4 insertions(+), 7 deletions(-) delete mode 100644 test/salt/top.sls diff --git a/.travis.yml b/.travis.yml index 1dbacf8..d0a3a0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ env: global: - BS_PIP_ALLOWED=1 - BS_ECHO_DEBUG=1 + - SALT_ARGS="--local --retcode-passthrough --pillar-root=test/pillar --file-root=$PWD" matrix: - STATE=rsyncd - STATE=rsyncd.config @@ -21,14 +22,14 @@ install: - sudo salt-call grains.items --local script: - - sudo salt-call state.show_sls $STATE --local --retcode-passthrough --config-dir=test/etc - - sudo salt-call state.sls $STATE --local --retcode-passthrough --config-dir=test/etc + - 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 --local --retcode-passthrough --config-dir=test/etc > /tmp/second + - sudo salt-call state.sls $STATE $SALT_ARGS > /tmp/second - cat /tmp/second - bash -c '! grep -q "^Not Run:" /tmp/second' diff --git a/test/salt/top.sls b/test/salt/top.sls deleted file mode 100644 index 755c05c..0000000 --- a/test/salt/top.sls +++ /dev/null @@ -1,4 +0,0 @@ -base: - '*': - - rsyncd - - rsyncd.config From 3d829fe62fee6d954b6800916c3487a58568de78 Mon Sep 17 00:00:00 2001 From: jpic Date: Fri, 15 May 2015 02:17:21 +0200 Subject: [PATCH 19/22] Removed unused file --- test/etc/minion | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 test/etc/minion diff --git a/test/etc/minion b/test/etc/minion deleted file mode 100644 index a95a68b..0000000 --- a/test/etc/minion +++ /dev/null @@ -1,8 +0,0 @@ -file_roots: - base: - - /srv/formula/test/salt - - /srv/formula - -pillar_roots: - base: - - /srv/formula/test/pillar From 19c19d77470835eda08cf3eb82c72a2c9a593866 Mon Sep 17 00:00:00 2001 From: Martin Hoefling Date: Fri, 15 May 2015 17:46:58 +0200 Subject: [PATCH 20/22] Enable salt debug log in travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d0a3a0d..f68ff34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ env: global: - BS_PIP_ALLOWED=1 - BS_ECHO_DEBUG=1 - - SALT_ARGS="--local --retcode-passthrough --pillar-root=test/pillar --file-root=$PWD" + - SALT_ARGS="-l debug --local --retcode-passthrough --pillar-root=test/pillar --file-root=$PWD" matrix: - STATE=rsyncd - STATE=rsyncd.config From a4cd959337c0d10cea60aba1f3b53194148b06e0 Mon Sep 17 00:00:00 2001 From: Martin Hoefling Date: Fri, 15 May 2015 23:04:16 +0200 Subject: [PATCH 21/22] Improve docs for rsyncd state --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 30b3a04..06322f1 100644 --- a/README.rst +++ b/README.rst @@ -21,7 +21,7 @@ Available states ``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`` ------------ From 8847bc72dc4e54ce056afe5738bb988804b88b36 Mon Sep 17 00:00:00 2001 From: Martin Hoefling Date: Fri, 15 May 2015 23:16:45 +0200 Subject: [PATCH 22/22] Create rsyncd.conf if not present --- rsyncd/init.sls | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rsyncd/init.sls b/rsyncd/init.sls index a57bc33..8d277c9 100644 --- a/rsyncd/init.sls +++ b/rsyncd/init.sls @@ -1,11 +1,23 @@ {% 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: pkg.installed: - name: {{ rsyncd.pkg }} service.running: - name: {{ rsyncd.service }} - enable: True + - require: + - file: rsyncd_conf_exists {% if grains.os_family == 'Debian' %} /etc/default/rsync: