diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml index 2bf266c..d13ce99 100644 --- a/.github/workflows/molecule.yml +++ b/.github/workflows/molecule.yml @@ -22,6 +22,7 @@ jobs: - name: install - name: offline - name: online + - name: stop image: - name: ubuntu2204 command: /lib/systemd/systemd diff --git a/galaxy.yml b/galaxy.yml index 9044c16..23485b9 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,7 +1,7 @@ --- namespace: nephelaiio name: mongodb -version: 0.0.10 +version: 0.0.11 readme: README.md authors: - Ted Cook diff --git a/molecule/common/stop.yml b/molecule/common/stop.yml new file mode 100644 index 0000000..464a6f5 --- /dev/null +++ b/molecule/common/stop.yml @@ -0,0 +1,3 @@ +--- +- name: Import stop playbook + import_playbook: nephelaiio.mongodb.stop diff --git a/molecule/offline/verify.yml b/molecule/offline/verify.yml index 071cb4a..bbe8381 100644 --- a/molecule/offline/verify.yml +++ b/molecule/offline/verify.yml @@ -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" diff --git a/molecule/stop/molecule.yml b/molecule/stop/molecule.yml new file mode 100644 index 0000000..b7142ab --- /dev/null +++ b/molecule/stop/molecule.yml @@ -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 diff --git a/molecule/stop/prepare.yml b/molecule/stop/prepare.yml new file mode 100644 index 0000000..67b4f52 --- /dev/null +++ b/molecule/stop/prepare.yml @@ -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 diff --git a/molecule/stop/verify.yml b/molecule/stop/verify.yml new file mode 100644 index 0000000..8f5f9cb --- /dev/null +++ b/molecule/stop/verify.yml @@ -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 diff --git a/playbooks/stop.yml b/playbooks/stop.yml new file mode 100644 index 0000000..6f227b4 --- /dev/null +++ b/playbooks/stop.yml @@ -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