Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test and fix idempotency #87

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,26 @@ install:
# Check ansible version
- ansible --version

# Create ansible.cfg with correct roles_path
- 'printf "[defaults]\nroles_path=../" > ansible.cfg'
# Create ansible.cfg with correct roles_path and log file path
- touch ansible.log && { printf "[defaults]\nroles_path=../\nlog_path=ansible.log" > ansible.cfg; }

env:
- ANSIBLE_HOST_KEY_CHECKING=False

script:
- ansible-playbook tests/test.yml -v
- >
ansible-playbook tests/test.yml -v
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)

after_failure:
- sudo tail -n 100 /var/log/syslog
- ls -l /var/log/riak
- ls /var/log/riak/error.log* && cat $(ls -tr /var/log/riak/error.log*)
- ls /var/log/riak/solr.log* && cat $(ls -tr /var/log/riak/solr.log*)
- cat ansible.log

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
Expand Down
1 change: 1 addition & 0 deletions tasks/buckets.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
- name: Fetch existing bucket-types
command: '{{ riak_admin }} bucket-type list'
changed_when: False
register: types

- name: Create bucket types only if not found in list
Expand Down
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
- name: Reboot Riak to accept the new config and ensure it is enabled to start at bootup
service: name=riak enabled=yes state=restarted
when: riak_init_system == 'system'
changed_when: False ## This is a workaround for not disrupting idempotency. The proper idempotency fix would be running the task only when the relevant config files changed.

- name: Wait for Riak to start up before continuing
wait_for: "delay=5 timeout=30 host={{ riak_pb_bind_ip }} port={{ riak_pb_port }} state=started"
Expand Down
5 changes: 5 additions & 0 deletions tasks/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,28 @@
command: '{{ riak_admin }} security add-group {{ item }}'
with_items: '{{ riak_groups }}'
when: riak_groups is defined
changed_when: False ## This is a workaround for not disrupting idempotency.

- name: Create users
command: '{{ riak_admin }} security add-user {{ item.user }} password={{ item.password }} groups={{ item.groups }}'
with_items: "{{ riak_users }}"
when: (riak_users is defined) and (riak_groups is defined)
changed_when: False ## This is a workaround for not disrupting idempotency.

- name: Create users
command: '{{ riak_admin }} security add-user {{ item.user }} password={{ item.password }}'
with_items: "{{ riak_users }}"
when: (riak_users is defined) and (riak_groups is not defined)
changed_when: False ## This is a workaround for not disrupting idempotency.

- name: Create security sources
command: '{{ riak_admin }} security add-source {{ item.user }} {{ item.cidr }} {{ item.type }}'
with_items: '{{ riak_sources }}'
when: riak_sources is defined
changed_when: False ## This is a workaround for not disrupting idempotency.

- name: Set security permissions
command: '{{ riak_admin }} security grant {{ item.permissions }} on {{ item.scope }} to {{ item.subject }}'
with_items: '{{ riak_grants }}'
when: riak_grants is defined
changed_when: False ## This is a workaround for not disrupting idempotency.