Skip to content

Commit

Permalink
Add ip configuration test to hostfile scenario (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyphreak authored Jan 22, 2024
1 parent 440aec5 commit c5c30cd
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/hostfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- master
paths:
- 'playbooks/prepare.yml'
- 'molecule/hostfile/*.yml'
- '.github/workflows/hostfile.yml'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: nephelaiio
name: mongodb
version: 0.2.5
version: 0.2.6
readme: README.md
authors:
- Ted Cook <[email protected]>
Expand Down
5 changes: 5 additions & 0 deletions molecule/hostfile/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Import install playbook
import_playbook: nephelaiio.mongodb.install
vars:
mongodb_hosts_manage: true
11 changes: 7 additions & 4 deletions molecule/hostfile/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,18 @@ provisioner:
playbooks:
create: ../common/create.yml
prepare: ../common/prepare.yml
converge: ../common/install.yml
verify: ../common/verify.yml
destroy: ../common/destroy.yml
cleanup: ../common/cleanup.yml
config_options:
defaults:
callbacks_enabled: ansible.posix.profile_tasks
inventory:
hosts:
all:
vars:
mongodb_cluster_state_zero: /tmp/state.0.yml
mongodb_cluster_state_one: /tmp/state.1.yml
mongodb_cluster_state_two: /tmp/state.2.yml
verifier:
name: ansible
scenario:
Expand All @@ -77,5 +82,3 @@ scenario:
- converge
- side_effect
- verify
- destroy
- cleanup
77 changes: 77 additions & 0 deletions molecule/hostfile/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
- name: Gather cluster facts
hosts: mongodb_mongos
become: true
tasks:
- name: Gather MongoDB existing replica set members
community.mongodb.mongodb_shell:
eval: "sh.status()"
mongo_cmd: "{{ mongodb_shell | default(omit) }}"
register: mongodb_status
retries: 6
delay: 10

- name: Write MongoDB replicaset status
ansible.builtin.copy:
dest: "{{ mongodb_cluster_state_zero }}"
content: "{{ _content | to_nice_yaml(indent=2) }}"
mode: 0644
vars:
_status: "{{ mongodb_status.transformed_output.value }}"
_content: "{{ _status | nephelaiio.plugins.drop_attributes(['databases', 'shardingVersion']) }}"


- name: Reconfigure cluster with ip addresses
import_playbook: nephelaiio.mongodb.install
vars:
mongodb_hosts_manage: false


- name: Gather cluster facts
hosts: mongodb_mongos
become: true
tasks:
- name: Gather MongoDB existing replica set members
community.mongodb.mongodb_shell:
eval: "sh.status()"
mongo_cmd: "{{ mongodb_shell | default(omit) }}"
register: mongodb_status
retries: 6
delay: 10

- name: Write MongoDB replicaset status
ansible.builtin.copy:
dest: "{{ mongodb_cluster_state_one }}"
content: "{{ _content | to_nice_yaml(indent=2) }}"
mode: 0644
vars:
_status: "{{ mongodb_status.transformed_output.value }}"
_content: "{{ _status | nephelaiio.plugins.drop_attributes(['databases', 'shardingVersion']) }}"


- name: Reconfigure cluster with hostnames
import_playbook: nephelaiio.mongodb.install
vars:
mongodb_hosts_manage: true


- name: Gather cluster facts
hosts: mongodb_mongos
become: true
tasks:
- name: Gather MongoDB existing replica set members
community.mongodb.mongodb_shell:
eval: "sh.status()"
mongo_cmd: "{{ mongodb_shell | default(omit) }}"
register: mongodb_status
retries: 6
delay: 10

- name: Write MongoDB replicaset status
ansible.builtin.copy:
dest: "{{ mongodb_cluster_state_two }}"
content: "{{ _content | to_nice_yaml(indent=2) }}"
mode: 0644
vars:
_status: "{{ mongodb_status.transformed_output.value }}"
_content: "{{ _status | nephelaiio.plugins.drop_attributes(['databases', 'shardingVersion']) }}"
11 changes: 11 additions & 0 deletions molecule/hostfile/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: Verify shard registration
hosts: mongodb_mongos
tasks:
- name: Verify cluster ip reconfig state
ansible.builtin.command: |
diff {{ mongodb_cluster_state_zero }} {{ mongodb_cluster_state_one}}
- name: Verify cluster hostname reconfig state
ansible.builtin.command: |
diff {{ mongodb_cluster_state_one }} {{ mongodb_cluster_state_two}}
2 changes: 1 addition & 1 deletion roles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ roles:
scm: git
- name: mongodb
src: https://github.com/wpnops/ansible-role-mongodb.git
version: 0.1.17
version: 0.1.21
scm: git
- name: update
src: https://github.com/robertdebock/ansible-role-update.git
Expand Down

0 comments on commit c5c30cd

Please sign in to comment.