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 stop playbook #11

Merged
merged 5 commits into from
Nov 10, 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
1 change: 1 addition & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- name: install
- name: offline
- name: online
- name: stop
image:
- name: ubuntu2204
command: /lib/systemd/systemd
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.0.10
version: 0.0.11
readme: README.md
authors:
- Ted Cook <[email protected]>
Expand Down
3 changes: 3 additions & 0 deletions molecule/common/stop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Import stop playbook
import_playbook: nephelaiio.mongodb.stop
10 changes: 8 additions & 2 deletions molecule/offline/verify.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
---
- name: Verify mongos service
hosts: mongodb_mongos
vars:
_service: mongos.service
tasks:
- name: Collect service facts
ansible.builtin.service_facts:

- name: Debug Mongos service status
ansible.builtin.debug:
msg: "{{ services[_service] }}"

- name: Verify service run status
ansible.builtin.fail:
msg: "Mongos service is running"
when: services['mongos.service'].state != "inactive"
when: services[_service].state not in ["inactive", "stopped"]

- name: Verify service boot status
ansible.builtin.fail:
msg: "Mongos service is enabled"
when: services['mongos.service'].status != "disabled"
when: services[_service].status != "disabled"
143 changes: 143 additions & 0 deletions molecule/stop/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
---
dependency:
name: galaxy
options:
role-file: requirements.yml
requirements-file: requirements.yml
driver:
name: docker
platforms:
- name: mongodb-stop-mongos01
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
privileged: true
pre_build_image: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /tmp
- /opt
groups:
- mongodb_mongos
- mongodb
- name: mongodb-stop-mongos02
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
privileged: true
pre_build_image: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /tmp
- /opt
groups:
- mongodb_mongos
- mongodb
- name: mongodb-stop-config01
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
privileged: true
pre_build_image: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /tmp
- /opt
groups:
- mongodb_config
- mongodb
- name: mongodb-stop-config02
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
privileged: true
pre_build_image: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /tmp
- /opt
groups:
- mongodb_config
- mongodb
- name: mongodb-stop-config03
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
privileged: true
pre_build_image: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /tmp
- /opt
groups:
- mongodb_config
- mongodb
- name: mongodb-stop-shard01
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
privileged: true
pre_build_image: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /tmp
- /opt
groups:
- mongodb_shard1
- mongodb
- name: mongodb-stop-shard02
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
privileged: true
pre_build_image: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /tmp
- /opt
groups:
- mongodb_shard1
- mongodb
- name: mongodb-stop-shard03
image: "geerlingguy/docker-${MOLECULE_DOCKER_IMAGE:-ubuntu2004}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
cgroupns_mode: host
privileged: true
pre_build_image: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /tmp
- /opt
groups:
- mongodb_shard1
- mongodb
provisioner:
name: ansible
playbooks:
converge: ../common/stop.yml
config_options:
defaults:
callbacks_enabled: ansible.posix.profile_tasks
verifier:
name: ansible
scenario:
test_sequence:
- dependency
- cleanup
- destroy
- create
- prepare
- converge
- idempotence
- side_effect
- verify
- cleanup
- destroy
6 changes: 6 additions & 0 deletions molecule/stop/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Include shared prepare play
ansible.builtin.import_playbook: ../common/prepare.yml

- name: Include shared install play
ansible.builtin.import_playbook: ../common/install.yml
45 changes: 45 additions & 0 deletions molecule/stop/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
- name: Verify mongos service
hosts: mongodb_mongos
vars:
_service: mongos.service
tasks:
- name: Collect service facts
ansible.builtin.service_facts:

- name: Debug Mongos service status
ansible.builtin.debug:
msg: "{{ services[_service] }}"

- name: Verify service run status
ansible.builtin.fail:
msg: "Mongos service is running"
when: services[_service].state not in ["inactive", "stopped"]

- name: Verify service boot status
ansible.builtin.fail:
msg: "Mongos service is enabled"
when: services[_service].status != "disabled"

- name: Verify mongodb service
hosts: mongodb_mongos:mongodb_config:mongodb_shard1
vars:
_service: mongod.service
tasks:
- name: Collect service facts
ansible.builtin.service_facts:

- name: Debug MongoDB service status
ansible.builtin.debug:
msg: "{{ services[_service] }}"

- name: Verify service run status
ansible.builtin.fail:
msg: "MongoDB service is running"
when: services[_service].state not in ["inactive", "stopped"]

- name: Verify service boot status
ansible.builtin.fail:
msg: "MongoDB service is enabled"
when: services[_service].status != "disabled"
tags: never
25 changes: 25 additions & 0 deletions playbooks/stop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Stop mongos services
hosts: "{{ mongodb_mongos | default('mongodb_mongos') }}"
become: true
tasks:
- name: Include mongos service tasks
ansible.builtin.include_role:
name: nephelaiio.mongodb.mongos
tasks_from: service
vars:
mongos_service_state: stopped


- name: Stop mongod services
hosts:
- "{{ mongodb_config | default('mongodb_config') }}"
- "{{ mongodb_shard1 | default('mongodb_shard1') }}"
become: true
tasks:
- name: Include mongos service tasks
ansible.builtin.include_role:
name: nephelaiio.mongodb.mongodb
tasks_from: service
vars:
mongodb_service_state: stopped