-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6f14fb
commit 7fd9527
Showing
8 changed files
with
183 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
- name: Deploy mongodb mongos servers | ||
hosts: mongos | ||
become: true | ||
roles: | ||
- nephelaiio.mongos | ||
pre_tasks: | ||
- name: Query package versions | ||
ansible.builtin.shell: | ||
cmd: "apt-cache madison {{ item }} | awk -F'|' '{ print $2 }'" | ||
loop: "{{ mongos_package_name }}" | ||
register: _mongos_package_query | ||
changed_when: false | ||
|
||
- name: Initialize package versions | ||
ansible.builtin.set_fact: | ||
mongos_package_name: [] | ||
|
||
- name: Verify target package versions | ||
ansible.builtin.fail: | ||
msg: "{{ _package }} has no installation candidate: {{ item }}" | ||
vars: | ||
_stdout: "{{ item.stdout_lines }}" | ||
_package: "{{ item.item }}" | ||
loop_control: | ||
label: "{{ item.item }}" | ||
loop: "{{ _mongos_package_query.results }}" | ||
when: _stdout | length == 0 | ||
|
||
- name: Set target package versions | ||
ansible.builtin.set_fact: | ||
mongos_package_name: "{{ mongos_package_name + [_package] }}" | ||
vars: | ||
_stdout: "{{ item.stdout_lines }}" | ||
_multiple: "{{ _stdout | length > 1 }}" | ||
_version: "{{ _stdout[0] if not _multiple else _stdout[1] }}" | ||
_package: "{{ item.item }}={{ _version | trim }}" | ||
loop_control: | ||
label: "{{ item.item }}" | ||
loop: "{{ _mongos_package_query.results }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
options: | ||
role-file: requirements.yml | ||
requirements-file: requirements.yml | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: mongos-hold-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: | ||
- mongos | ||
- name: mongos-hold-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: | ||
- mongos | ||
provisioner: | ||
name: ansible | ||
inventory: | ||
hosts: | ||
all: | ||
vars: | ||
mongos_service_name: mongos | ||
mongos_service_manage: false | ||
mongos_service_restart: false | ||
mongos_replicaset_config_name: config | ||
mongos_replicaset_shard_name: shard | ||
mongodb_shell: mongosh | ||
mongos_package_name: | ||
- mongodb-org-server | ||
- mongodb-org-mongos | ||
- mongodb-mongosh | ||
- pkg-config | ||
scenario: | ||
converge_sequence: | ||
- converge | ||
test_sequence: | ||
- destroy | ||
- dependency | ||
- create | ||
- prepare | ||
- converge | ||
- verify | ||
verifier: | ||
name: ansible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: Prepare mongos servers | ||
hosts: mongos | ||
become: true | ||
roles: | ||
- nephelaiio.mongodb_repo | ||
pre_tasks: | ||
- name: Update apt package cache | ||
ansible.builtin.apt: | ||
update_cache: yes | ||
when: ansible_os_family == 'Debian' | ||
changed_when: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
- name: Verify mongos deployment | ||
hosts: mongos | ||
become: true | ||
tasks: | ||
- name: Query package versions | ||
ansible.builtin.shell: | ||
cmd: "apt-cache madison {{ item }} | awk -F'|' '{ print $2 }'" | ||
loop: "{{ mongos_package_name }}" | ||
register: _mongos_package_query | ||
changed_when: false | ||
|
||
- name: Initialize package versions | ||
ansible.builtin.set_fact: | ||
mongos_package_name: [] | ||
|
||
- name: Set target package versions | ||
ansible.builtin.set_fact: | ||
mongos_package_name: "{{ mongos_package_name + [_package] }}" | ||
vars: | ||
_stdout: "{{ item.stdout_lines }}" | ||
_multiple: "{{ _stdout | length > 1 }}" | ||
_version: "{{ _stdout[0] if not _multiple else _stdout[1] }}" | ||
_package: "{{ item.item }}={{ _version | trim }}" | ||
loop_control: | ||
label: "{{ item.item }}" | ||
loop: "{{ _mongos_package_query.results }}" | ||
|
||
- name: Gather package facts | ||
ansible.builtin.package_facts: | ||
|
||
- name: Verify package versions | ||
ansible.builtin.fail: | ||
msg: "Expected installed version for package {{ _package }} to be {{ _version }}, found {{ _installed }}" | ||
vars: | ||
_package: "{{ item.split('=') | first }}" | ||
_version: "{{ item.split('=') | last }}" | ||
_installed: "{{ (packages[_package] | default([{'version': 'None'}]))[0].version }}" | ||
loop: "{{ mongos_package_name }}" | ||
when: _package not in packages or _version != _installed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
- name: Configure apt package holds | ||
ansible.builtin.dpkg_selections: | ||
name: "{{ item.split('=') | first }}" | ||
selection: "{{ _lock_state }}" | ||
vars: | ||
_version_regex: ".*=.*" | ||
_package_versions: "{{ [mongos_package_name] | flatten | map('regex_search', _version_regex) }}" | ||
_package_holds: "{{ _package_versions | select('string') }}" | ||
loop: "{{ _package_holds }}" | ||
when: ansible_os_family == "Debian" | ||
changed_when: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters