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

Add cluster tests to restart play #17

Merged
merged 1 commit into from
Nov 14, 2023
Merged
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
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.0.14
version: 0.0.15
readme: README.md
authors:
- Ted Cook <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion molecule/restart/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ provisioner:
playbooks:
prepare: ../common/prepare.yml
converge: ../common/install.yml
side-effect: ../common/restart.yml
side_effect: ../common/restart.yml
verify: ../common/verify.yml
config_options:
defaults:
Expand Down
52 changes: 48 additions & 4 deletions playbooks/restart.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
---
- name: Restart mongod services
- name: Restart config services
serial: 1
hosts:
- "{{ mongodb_config | default('mongodb_config') }}"
- "{{ mongodb_shard1 | default('mongodb_shard1') }}"
hosts: "{{ mongodb_config | default('mongodb_config') }}"
become: true
pre_tasks:
- name: Include collection variables
ansible.builtin.include_vars:
file: main.yml
tasks:
- name: Include mongos service tasks
ansible.builtin.include_role:
Expand All @@ -13,15 +15,57 @@
vars:
mongos_service_state: restarted

- name: Wait for replica set to stabilize
community.mongodb.mongodb_status:
replica_set: "{{ mongos_replicaset_config_name | default('config') }}"
validate: minimal
poll: "{{ mongodb_reconfig_poll }}"
interval: "{{ mongodb_reconfig_interval }}"


- name: Restart shard1 services
serial: 1
hosts: "{{ mongodb_shard1 | default('mongodb_shard1') }}"
become: true
pre_tasks:
- name: Include collection variables
ansible.builtin.include_vars:
file: main.yml
tasks:
- name: Include mongos service tasks
ansible.builtin.include_role:
name: nephelaiio.mongodb.mongodb
tasks_from: service
vars:
mongos_service_state: restarted

- name: Wait for replica set to stabilize
community.mongodb.mongodb_status:
replica_set: "{{ mongos_replicaset_shard1_name | default('shard1') }}"
validate: minimal
poll: "{{ mongodb_reconfig_poll }}"
interval: "{{ mongodb_reconfig_interval }}"


- name: Restart mongos services
hosts: "{{ mongodb_mongos | default('mongodb_mongos') }}"
become: true
serial: 1
pre_tasks:
- name: Include collection variables
ansible.builtin.include_vars:
file: main.yml
tasks:
- name: Include mongos service tasks
ansible.builtin.include_role:
name: nephelaiio.mongodb.mongos
tasks_from: service
vars:
mongos_service_state: restarted

- name: Check mongos cluster status
community.mongodb.mongodb_shell:
login_database: "admin"
eval: "sh.status()"
retries: "{{ mongodb_reconfig_poll }}"
delay: "{{ mongodb_reconfig_interval }}"
2 changes: 2 additions & 0 deletions playbooks/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ mongodb_address_attrs: ['ansible_default_ipv4', 'address']
mongodb_port: '27017'
mongos_service_name: 'mongos'
mongodb_shell: 'mongosh'
mongodb_reconfig_poll: 6
mongodb_reconfig_interval: 10
3 changes: 3 additions & 0 deletions roles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ roles:
src: https://github.com/wpnops/ansible-role-mongodb.git
version: 0.1.6
scm: git
- name: update
src: https://github.com/robertdebock/ansible-role-update.git
version: 3.1.7