2015-02-09 18:39:32 +06:00
---
2015-02-17 19:17:20 +06:00
- include : auth_initialization_ald.yml
when : ansible_local.mongodb.mongodb.mongodb_login_port is defined
2015-03-02 16:07:44 +06:00
- name : create administrative user siteUserAdmin
2015-02-10 13:45:52 +06:00
mongodb_user :
2015-02-09 18:39:32 +06:00
database : admin
name : "{{ item.name }}"
password : "{{ item.password }}"
roles : "{{ item.roles }}"
2015-04-06 18:53:40 +03:00
login_host : "{{ mongodb_listen_ip }}"
2015-02-09 18:39:32 +06:00
with_items :
2015-02-10 13:45:52 +06:00
- {
2015-03-02 16:07:44 +06:00
name : "{{ mongodb_user_admin_name }}" ,
password : "{{ mongodb_user_admin_password }}" ,
roles : "userAdminAnyDatabase"
2015-02-09 18:39:32 +06:00
}
2015-03-02 16:07:44 +06:00
register : useradmin_user_result
2015-02-17 19:17:20 +06:00
when : ansible_local.mongodb.mongodb.mongodb_login_port is undefined
2015-02-09 18:39:32 +06:00
2015-03-02 16:07:44 +06:00
- name : create administrative user siteRootAdmin
2015-02-10 13:45:52 +06:00
mongodb_user :
2015-02-09 18:39:32 +06:00
database : admin
name : "{{ item.name }}"
password : "{{ item.password }}"
roles : "{{ item.roles }}"
2015-04-06 18:53:40 +03:00
login_host : "{{ mongodb_listen_ip }}"
2015-03-03 11:21:25 +06:00
login_user : "{{ mongodb_user_admin_name }}"
login_password : "{{ mongodb_user_admin_password }}"
2015-02-09 18:39:32 +06:00
with_items :
2015-02-10 13:45:52 +06:00
- {
2015-03-02 16:07:44 +06:00
name : "{{ mongodb_root_admin_name }}" ,
password : "{{ mongodb_root_admin_password }}" ,
roles : "root"
2015-02-09 18:39:32 +06:00
}
2015-03-02 16:07:44 +06:00
register : rootadmin_user_result
2015-02-17 19:17:20 +06:00
when : ansible_local.mongodb.mongodb.mongodb_login_port is undefined
2015-02-09 18:39:32 +06:00
- name : create normal users
mongodb_user :
database : "{{ item.database }}"
name : "{{ item.name }}"
password : "{{ item.password }}"
roles : "{{ item.roles }}"
2015-02-17 13:26:56 +06:00
replica_set : "{{ mongodb_conf_replSet }}"
2015-04-06 18:53:40 +03:00
login_host : "{{ mongodb_listen_ip }}"
2015-02-17 13:26:56 +06:00
login_user : "{{ mongodb_user_admin_name }}"
login_password : "{{ mongodb_user_admin_password }}"
2015-02-09 18:39:32 +06:00
with_items :
2015-02-10 13:45:52 +06:00
- "{{ mongodb_users }}"
2015-02-17 19:43:13 +06:00
when : mongodb_users is defined and ansible_local.mongodb.mongodb.mongodb_login_port is undefined
2015-02-17 19:17:20 +06:00
- name : Create facts.d directory
2015-04-06 18:53:40 +03:00
file : path=/etc/ansible/facts.d state=directory recurse=yes
2015-04-04 14:26:31 +03:00
when : (ansible_local.mongodb.mongodb.mongodb_login_port is undefined) and (rootadmin_user_result|changed or useradmin_user_result|changed or config_result|changed)
2015-02-17 19:17:20 +06:00
- name : Create facts file for mongodb
2015-04-06 18:53:40 +03:00
template : src=mongodb.fact.j2 dest=/etc/ansible/facts.d/mongodb.fact
2015-04-04 14:26:31 +03:00
when : (ansible_local.mongodb.mongodb.mongodb_login_port is undefined) and (rootadmin_user_result|changed or useradmin_user_result|changed or config_result|changed)