Skip to content

Commit

Permalink
Build from source idempotence. Closes #7
Browse files Browse the repository at this point in the history
pjan vandaele committed Jul 11, 2014
1 parent 0ede3c6 commit a4042ec
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -10,3 +10,10 @@ script:
- echo localhost > inventory
- ansible-playbook --syntax-check -i inventory test.yml
- ansible-playbook -i inventory test.yml --connection=local --sudo
# Taken from https://servercheck.in/blog/testing-ansible-roles-travis-ci-github
# Run the role/playbook again, checking to make sure it's idempotent.
- >
ansible-playbook -i inventory test.yml --connection=local --sudo
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
10 changes: 9 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
@@ -2,5 +2,13 @@

- include: package.yml
when: nodejs_install_method == "package"
- include: source.yml

- name: node.js | Check if the node version is already installed
command: node --version
ignore_errors: yes
register: node_version
changed_when: node_version.rc != 0 or node_version.stdout != "v{{ nodejs_version }}"
when: nodejs_install_method == "source"

- include: source.yml
when: nodejs_install_method == "source" and node_version.changed

0 comments on commit a4042ec

Please sign in to comment.