Skip to content

Commit

Permalink
Add cluster offline playbook
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyphreak committed Nov 7, 2023
1 parent 0588bc4 commit f28cd4c
Show file tree
Hide file tree
Showing 14 changed files with 192 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
strategy:
matrix:
scenario:
- name: default
- name: install
- name: online
image:
- name: ubuntu2204
command: /lib/systemd/systemd
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all ${MAKECMDGOALS}

MOLECULE_SCENARIO ?= default
MOLECULE_SCENARIO ?= install
MOLECULE_DOCKER_IMAGE ?= ubuntu2004
GALAXY_API_KEY ?=
GITHUB_REPOSITORY ?= $$(git config --get remote.origin.url | cut -d: -f 2 | cut -d. -f 1)
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions molecule/common/offline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Import offline playbook
import_playbook: nephelaiio.mongodb.offline
File renamed without changes.
24 changes: 0 additions & 24 deletions molecule/default/destroy.yml

This file was deleted.

3 changes: 0 additions & 3 deletions molecule/default/side_effect.yml

This file was deleted.

145 changes: 145 additions & 0 deletions molecule/install/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
---
dependency:
name: galaxy
options:
role-file: requirements.yml
requirements-file: requirements.yml
driver:
name: docker
platforms:
- name: 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: 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: 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: 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: 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: 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: 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: 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:
prepare: ../common/prepare.yml
converge: ../common/install.yml
side-effect: ../common/install.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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Import install playbook
- name: Verify shard registration
hosts: mongodb_mongos
tasks:
- name: Verify shard registration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ platforms:
- mongodb
provisioner:
name: ansible
playbooks:
converge: ../common/offline.yml
config_options:
defaults:
callbacks_enabled: ansible.posix.profile_tasks
verifier:
name: ansible
scenario:
Expand Down
6 changes: 6 additions & 0 deletions molecule/offline/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
16 changes: 16 additions & 0 deletions molecule/offline/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Verify mongos service
hosts: mongodb_mongos
tasks:
- name: Collect service facts
ansible.builtin.service_facts:

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

- name: Verify service boot status
ansible.builtin.fail:
msg: "Mongos service is enabled"
when: services['mongos.service'].status != "disabled"
11 changes: 11 additions & 0 deletions playbooks/offline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- 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
4 changes: 2 additions & 2 deletions roles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ roles:
version: 0.0.15
- name: mongos
src: https://github.com/nephelaiio/ansible-role-mongos.git
version: 0.0.3
version: 0.0.6
- name: mongodb
src: https://github.com/wpnops/ansible-role-mongodb.git
version: 0.1.4
version: 0.1.5
scm: git
- name: plugins
src: https://github.com/nephelaiio/ansible-role-plugins.git
Expand Down

0 comments on commit f28cd4c

Please sign in to comment.