|
1 | 1 | --- |
2 | 2 | # tasks file for mongodb_auth |
3 | 3 | - name: Include OS-specific vars |
4 | | - include_vars: |
| 4 | + ansible.builtin.include_vars: |
5 | 5 | file: "{{ lookup('first_found', params) }}" |
6 | 6 | vars: |
7 | 7 | params: |
|
17 | 17 | - "vars" |
18 | 18 |
|
19 | 19 | - name: Ensure mongod and pyyaml packages are installed |
20 | | - package: |
| 20 | + ansible.builtin.package: |
21 | 21 | name: |
22 | 22 | - "{{ mongod_package }}" |
23 | 23 | # pyyaml is used to validate yaml files on change |
|
30 | 30 |
|
31 | 31 | - name: Warn about default credentials |
32 | 32 | when: mongodb_admin_pwd == mongodb_default_admin_pwd |
33 | | - debug: |
| 33 | + ansible.builtin.debug: |
34 | 34 | msg: "[WARNING] Using default admin credentials for mongodb admin account! Please change them!" |
35 | 35 | tags: |
36 | 36 | - "debug" |
37 | 37 |
|
38 | 38 | - name: Enable security section in mongod.conf |
39 | | - lineinfile: |
| 39 | + ansible.builtin.lineinfile: |
40 | 40 | path: /etc/mongod.conf |
41 | 41 | regexp: |- |
42 | 42 | ^[#'"\s]*security['"]?\s*: |
|
52 | 52 | - "setup" |
53 | 53 |
|
54 | 54 | - name: Enable authentication in mongod.conf |
55 | | - lineinfile: |
| 55 | + ansible.builtin.lineinfile: |
56 | 56 | path: /etc/mongod.conf |
57 | 57 | insertafter: '^security:' |
58 | 58 | # two space indentation (the default) assumed |
|
74 | 74 | - name: Restart mongodb to enable auth before adding additional users |
75 | 75 | # This allows us to safely assume auth is already enabled when adding more users |
76 | 76 | when: _enable_mongo_auth is changed |
77 | | - service: |
| 77 | + ansible.builtin.service: |
78 | 78 | name: mongod |
79 | 79 | state: restarted |
80 | 80 | tags: |
|
105 | 105 | - "admin_user" |
106 | 106 |
|
107 | 107 | - name: Add additional mongo users |
108 | | - include_tasks: mongodb_auth_user.yml |
| 108 | + ansible.builtin.include_tasks: mongodb_auth_user.yml |
109 | 109 | loop: "{{ mongodb_users }}" |
110 | 110 | loop_control: |
111 | 111 | loop_var: _mongodb_user |
|
0 commit comments