ansible-role-mongodb/tasks/auth_initialization.yml

77 lines
1.9 KiB
YAML
Raw Normal View History

2015-02-09 18:39:32 +06:00
---
2018-02-26 15:35:36 +07:00
- name: Use different mongod.conf for auth initialization
2019-05-23 00:37:39 -04:00
template:
src: mongod_init.conf.j2
dest: /etc/mongod.conf
owner: root
group: root
mode: 0644
notify:
- mongodb restart
- wait when mongodb is started on localhost
2015-02-09 18:39:32 +06:00
2019-05-23 00:37:39 -04:00
- name: Flush all handlers at this point
meta: flush_handlers
2015-11-22 11:58:35 +02:00
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 }}"
2016-04-17 19:43:00 +06:00
update_password: "{{ mongodb_user_update_password }}"
2015-02-09 18:39:32 +06:00
roles: "{{ item.roles }}"
2016-04-17 19:43:00 +06:00
login_port: "{{ mongodb_net_port }}"
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
}
no_log: true
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 }}"
2016-04-17 19:43:00 +06:00
update_password: "{{ mongodb_user_update_password }}"
2015-02-09 18:39:32 +06:00
roles: "{{ item.roles }}"
2016-04-17 19:43:00 +06:00
login_port: "{{ mongodb_net_port }}"
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
}
no_log: true
2015-02-09 18:39:32 +06:00
2015-11-17 12:14:41 +06:00
- name: create backup user "backupuser"
mongodb_user:
database: admin
name: "{{ item.name }}"
password: "{{ item.password }}"
2016-04-18 19:08:24 +06:00
update_password: "{{ mongodb_user_update_password }}"
2015-11-17 12:14:41 +06:00
roles: "{{ item.roles }}"
2016-04-18 19:08:24 +06:00
login_port: "{{ mongodb_net_port }}"
2015-11-17 12:14:41 +06:00
with_items:
- {
name: "{{ mongodb_root_backup_name }}",
password: "{{ mongodb_root_backup_password }}",
roles: "backup,clusterMonitor"
}
no_log: true
2015-11-17 12:14:41 +06:00
- name: Move back mongod.conf
2019-05-23 00:37:39 -04:00
template:
src: mongod.conf.j2
dest: /etc/mongod.conf
owner: root
group: root
mode: 0644
notify:
- mongodb restart
- wait when mongodb is started
2019-05-23 00:37:39 -04:00
- name: Flush all handlers at this point
meta: flush_handlers