Debian Codegraph @

ansible_collections/community/mongodb/roles/mongodb_auth/molecule/default/converge.yml

raw
1 ---
2 - name: Converge
3 hosts: all
4 vars:
5 # for this test, each machine is an isolated mongod instance
6 replicaset: false
7 sharding: false
8
9 # initially disable authorization on some hosts
10 hosts_with_auth_disabled:
11 - ubuntu2204
12 - debian12
13 - rockylinux9
14
15 # add some users for some of the hosts
16 hosts_with_extra_user:
17 - almalinux9
18 - debian12
19 - amazon2023
20 mongodb_users_empty: []
21 mongodb_users_full:
22 - db: somedatabase
23 user: someuser
24 pwd: "S0meP@ss"
25 roles: readWrite
26 - db: somedatabase
27 user: otheruser
28 pwd: "0th3rP@ss"
29 roles: readWrite
30 mongodb_users: "{% if inventory_hostname in hosts_with_extra_user %}{{ mongodb_users_full }}{% else %}{{ mongodb_users_empty }}{% endif %}"
31
32 roles:
33 - role: community.mongodb.mongodb_repository
34 tags: molecule-idempotence-notest
35 - role: community.mongodb.mongodb_mongod
36 authorization: "{% if inventory_hostname in hosts_with_auth_disabled %}disabled{% else %}enabled{% endif %}"
37 tags: molecule-idempotence-notest # avoids false positive where replacing conf file disables authorization again
38
39 tasks:
40 #- name: Add EPEL repo to CentOS 7 to allow installing pip package
41 # become: yes
42 # yum:
43 # name: epel-release
44 # state: present
45 # when: inventory_hostname == 'almalinux_8'
46
47 - name: Install pymongo
48 ansible.builtin.pip:
49 name: pymongo
50 when:
51 - ansible_hostname != "debian12"
52
53 - name: Install pymongo on Debian 12
54 ansible.builtin.command: pip install pymongo --break-system-packages
55 when:
56 - ansible_hostname == "debian12"
57 changed_when: False
58
59 - name: Enable mongo auth
60 ansible.builtin.include_role:
61 name: community.mongodb.mongodb_auth
62
63 - name: Determine openssl version
64 ansible.builtin.command: openssl version
65 changed_when: false
66 register: openssl
67
68 - name: Set mongosh package version
69 ansible.builtin.set_fact:
70 mongosh_package: "{{ 'mongodb-mongosh-shared-openssl3' if openssl.stdout.startswith('OpenSSL 3') else 'mongodb-mongosh-shared-openssl11' }}"
71 when: mongosh_package is not defined
72
73 - name: Install MongoDB Shell
74 ansible.builtin.package:
75 name:
76 - "{{ mongosh_package }}"