Skip to content

Commit

Permalink
Rename mongos package parameter (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
teddyphreak authored Nov 23, 2023
1 parent 9248fd2 commit 4067c7e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
mongos_package_name:
mongos_packages:
- mongodb-org-server
- mongodb-org-mongos
- mongodb-mongosh
Expand Down
10 changes: 5 additions & 5 deletions molecule/hold/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
- name: Query Debian package versions
ansible.builtin.shell:
cmd: "apt-cache madison {{ item }} | awk -F'|' '{ print $2 }'"
loop: "{{ mongos_package_name }}"
loop: "{{ mongos_packages }}"
register: _debian_package_query
when: ansible_os_family == "Debian"
changed_when: false

- name: Query RedHat package versions
ansible.builtin.shell:
cmd: "yum list {{ item }} --showduplicates | grep '^{{ item }}' | awk '{ print $1,$2 }' | sort -r"
loop: "{{ mongos_package_name }}"
loop: "{{ mongos_packages }}"
register: _redhat_package_query
when: ansible_os_family == "RedHat"
changed_when: false
Expand All @@ -41,11 +41,11 @@

- name: Initialize package versions
ansible.builtin.set_fact:
mongos_package_name: []
mongos_packages: []

- name: Set target Debian package versions
ansible.builtin.set_fact:
mongos_package_name: "{{ mongos_package_name + [_package] }}"
mongos_packages: "{{ mongos_packages + [_package] }}"
vars:
_stdout: "{{ item.stdout_lines }}"
_multiple: "{{ _stdout | length > 1 }}"
Expand All @@ -58,7 +58,7 @@

- name: Set target RedHat package versions
ansible.builtin.set_fact:
mongos_package_name: "{{ mongos_package_name + [_package] }}"
mongos_packages: "{{ mongos_packages + [_package] }}"
vars:
_stdout: "{{ item.stdout_lines }}"
_multiple: "{{ _stdout | length > 1 }}"
Expand Down
2 changes: 1 addition & 1 deletion molecule/hold/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ provisioner:
mongos_replicaset_config_name: config
mongos_replicaset_shard_name: shard
mongodb_shell: mongosh
mongos_package_name:
mongos_packages:
- mongodb-org-server
- mongodb-org-mongos
- mongodb-mongosh
Expand Down
6 changes: 3 additions & 3 deletions molecule/hold/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
- name: Query Debian package versions
ansible.builtin.shell:
cmd: "apt-cache madison {{ item }} | awk -F'|' '{ print $2 }'"
loop: "{{ mongos_package_name }}"
loop: "{{ mongos_packages }}"
register: _debian_package_query
when: ansible_os_family == 'Debian'
changed_when: false

- name: Query RedHat package versions
ansible.builtin.shell:
cmd: "yum list {{ item }} --showduplicates | grep '^{{ item }}' | awk '{ print $1,$2 }' | sort -r"
loop: "{{ mongos_package_name }}"
loop: "{{ mongos_packages }}"
register: _redhat_package_query
when: ansible_os_family == "RedHat"
changed_when: false
Expand Down Expand Up @@ -83,7 +83,7 @@
_package: "{{ item.0 }}"
_version: "{{ item.1 | regex_replace(_prefix, '') | regex_replace(_suffix, '') }}"
_installed: "{{ (packages[_package] | default([{'version': 'None'}]))[0].version }}"
loop: "{{ mongos_package_name | zip(mongos_package_list) }}"
loop: "{{ mongos_packages | zip(mongos_package_list) }}"
when:
- ansible_os_family == "RedHat"
- _package not in packages or _version != _installed
4 changes: 2 additions & 2 deletions tasks/lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
selection: "{{ _lock_state }}"
vars:
_version_regex: ".*=.*"
_package_versions: "{{ [mongos_package_name] | flatten | map('regex_search', _version_regex) }}"
_package_versions: "{{ [mongos_packages] | flatten | map('regex_search', _version_regex) }}"
_package_holds: "{{ _package_versions | select('string') }}"
loop: "{{ _package_holds }}"
when: ansible_os_family == "Debian"
Expand All @@ -17,7 +17,7 @@
state: "{{ 'absent' if _lock_state == 'install' else 'present' }}"
vars:
_version_regex: ".*=.*"
_package_versions: "{{ [mongos_package_name] | flatten | map('regex_search', _version_regex) }}"
_package_versions: "{{ [mongos_packages] | flatten | map('regex_search', _version_regex) }}"
_package_holds: "{{ _package_versions | select('string') }}"
loop: "{{ _package_holds }}"
when: ansible_os_family == "RedHat"
Expand Down
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
block:
- name: Install packages
ansible.builtin.package:
name: "{{ mongos_package_name }}"
name: "{{ mongos_packages }}"
state: "{{ mongos_package_state }}"

always:
Expand Down

0 comments on commit 4067c7e

Please sign in to comment.