ansible-role-mongodb/tasks/auth_initialization_ald.yml

48 lines
1.5 KiB
YAML

---
- name: create administrative user siteUserAdmin port=yes
mongodb_user:
database: admin
name: "{{ item.name }}"
password: "{{ item.password }}"
roles: "{{ item.roles }}"
login_host: "{{ mongodb_listen_ip }}"
login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}"
with_items:
- {
name: "{{ mongodb_user_admin_name }}",
password: "{{ mongodb_user_admin_password }}",
roles: "userAdminAnyDatabase"
}
- name: create administrative user siteRootAdmin port=yes
mongodb_user:
database: admin
name: "{{ item.name }}"
password: "{{ item.password }}"
roles: "{{ item.roles }}"
login_host: "{{ mongodb_listen_ip }}"
login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}"
login_user: "{{ mongodb_user_admin_name }}"
login_password: "{{ mongodb_user_admin_password }}"
with_items:
- {
name: "{{ mongodb_root_admin_name }}",
password: "{{ mongodb_root_admin_password }}",
roles: "root"
}
- name: create normal users port=yes
mongodb_user:
database: "{{ item.database }}"
name: "{{ item.name }}"
password: "{{ item.password }}"
roles: "{{ item.roles }}"
replica_set: "{{ mongodb_conf_replSet }}"
login_host: "{{ mongodb_listen_ip }}"
login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}"
login_user: "{{ mongodb_user_admin_name }}"
login_password: "{{ mongodb_user_admin_password }}"
with_items:
- "{{ mongodb_users }}"
when: mongodb_users is defined