Debian Codegraph @

ansible_collections/community/mongodb/roles/mongodb_auth/tasks/mongodb_auth_user.yml

raw
1 ---
2 - name: "Add mongo auth user - {{ _mongodb_user.user }} on {{ _mongodb_user.db }}"
3 community.mongodb.mongodb_user:
4 state: "{{ _mongodb_user.state|default('present') }}"
5
6 # NOTE: on_create is idempotent, always is not.
7 # With `update_password: on_create`, mongodb_user checks to see if the user
8 # (a) exists on the db, and (b) has the same roles,
9 # and then it only adds the user if it's not there or the roles have changed.
10 # With `update_password: always`, mongodb_user cannot tell if the password
11 # needs to be changed without attempting a login with those credentials.
12 # But mongodb_user does not currently implement such a check.
13 # A comment in mongodb_user points to https://jira.mongodb.org/browse/SERVER-22848
14 update_password: "{{ mongodb_force_update_password|ternary('always', 'on_create') }}"
15
16 name: "{{ _mongodb_user.user }}"
17 password: "{{ _mongodb_user.pwd }}"
18 database: "{{ _mongodb_user.db }}"
19 roles: "{{ _mongodb_user.roles|default('readWrite') }}"
20
21 ssl: "{{ mongodb_use_tls }}"
22 ssl_ca_certs: "{{ mongodb_certificate_ca_file if mongodb_use_tls else omit }}"
23 login_host: "{{ mongod_host }}"
24 login_port: "{{ mongod_port | string }}" # silence implicit int->str conversion warning
25 login_user: "{{ mongodb_admin_user }}"
26 login_password: "{{ mongodb_admin_pwd }}"
27 login_database: admin
28 # to provide additional auth details (eg for ssl* or auth_mechanism, set module_defaults in playbook)
29 # module_defaults:
30 # community.mongodb.mongodb_user:
31 # auth_mechanism: ...
32 tags:
33 - "mongodb"
34 - "app_user"