2015-02-09 12:39:32 +00:00
|
|
|
---
|
2015-06-22 08:59:25 +00:00
|
|
|
- name: Move back mongod.conf
|
|
|
|
template: src=mongod_init.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0644
|
2015-02-09 12:39:32 +00:00
|
|
|
|
2015-06-22 08:59:25 +00:00
|
|
|
- name: Restart mongodb service
|
|
|
|
service: name={{ mongodb_daemon_name }} state=restarted
|
2015-06-28 19:54:04 +00:00
|
|
|
when: mongodb_manage_service
|
|
|
|
|
2015-11-22 09:58:35 +00:00
|
|
|
- name: wait MongoDB port is listening
|
2016-04-17 13:43:00 +00:00
|
|
|
wait_for: host=127.0.0.1 port="{{ mongodb_net_port }}" delay=5 state=started
|
2015-11-22 09:58:35 +00:00
|
|
|
|
2015-06-28 19:54:04 +00:00
|
|
|
- name: get pid of mongodb for non daemon mode
|
|
|
|
shell: "pidof mongod"
|
|
|
|
register: pidof_mongod
|
|
|
|
when: mongodb_manage_service == false
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: start mongodb daemon
|
|
|
|
shell: "LC_ALL=C /usr/bin/mongod --config /etc/mongod.conf --fork"
|
|
|
|
when: mongodb_manage_service == false and pidof_mongod.rc == 1
|
2015-02-17 13:17:20 +00:00
|
|
|
|
2015-03-02 10:07:44 +00:00
|
|
|
- name: create administrative user siteUserAdmin
|
2015-02-10 07:45:52 +00:00
|
|
|
mongodb_user:
|
2015-02-09 12:39:32 +00:00
|
|
|
database: admin
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
password: "{{ item.password }}"
|
2016-04-17 13:43:00 +00:00
|
|
|
update_password: "{{ mongodb_user_update_password }}"
|
2015-02-09 12:39:32 +00:00
|
|
|
roles: "{{ item.roles }}"
|
2016-04-17 13:43:00 +00:00
|
|
|
login_port: "{{ mongodb_net_port }}"
|
2015-02-09 12:39:32 +00:00
|
|
|
with_items:
|
2015-02-10 07:45:52 +00:00
|
|
|
- {
|
2015-03-02 10:07:44 +00:00
|
|
|
name: "{{ mongodb_user_admin_name }}",
|
|
|
|
password: "{{ mongodb_user_admin_password }}",
|
|
|
|
roles: "userAdminAnyDatabase"
|
2015-02-09 12:39:32 +00:00
|
|
|
}
|
|
|
|
|
2015-03-02 10:07:44 +00:00
|
|
|
- name: create administrative user siteRootAdmin
|
2015-02-10 07:45:52 +00:00
|
|
|
mongodb_user:
|
2015-02-09 12:39:32 +00:00
|
|
|
database: admin
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
password: "{{ item.password }}"
|
2016-04-17 13:43:00 +00:00
|
|
|
update_password: "{{ mongodb_user_update_password }}"
|
2015-02-09 12:39:32 +00:00
|
|
|
roles: "{{ item.roles }}"
|
2016-04-17 13:43:00 +00:00
|
|
|
login_port: "{{ mongodb_net_port }}"
|
2015-02-09 12:39:32 +00:00
|
|
|
with_items:
|
2015-02-10 07:45:52 +00:00
|
|
|
- {
|
2015-03-02 10:07:44 +00:00
|
|
|
name: "{{ mongodb_root_admin_name }}",
|
|
|
|
password: "{{ mongodb_root_admin_password }}",
|
|
|
|
roles: "root"
|
2015-02-09 12:39:32 +00:00
|
|
|
}
|
|
|
|
|
2015-11-17 06:14:41 +00:00
|
|
|
- name: create backup user "backupuser"
|
|
|
|
mongodb_user:
|
|
|
|
database: admin
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
password: "{{ item.password }}"
|
2016-04-18 13:08:24 +00:00
|
|
|
update_password: "{{ mongodb_user_update_password }}"
|
2015-11-17 06:14:41 +00:00
|
|
|
roles: "{{ item.roles }}"
|
2016-04-18 13:08:24 +00:00
|
|
|
login_port: "{{ mongodb_net_port }}"
|
2015-11-17 06:14:41 +00:00
|
|
|
with_items:
|
|
|
|
- {
|
|
|
|
name: "{{ mongodb_root_backup_name }}",
|
|
|
|
password: "{{ mongodb_root_backup_password }}",
|
|
|
|
roles: "backup,clusterMonitor"
|
|
|
|
}
|
|
|
|
|
2015-06-22 08:59:25 +00:00
|
|
|
- name: Move back mongod.conf
|
|
|
|
template: src=mongod.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0644
|
2015-04-04 11:26:31 +00:00
|
|
|
|
2015-06-22 08:59:25 +00:00
|
|
|
- name: Restart mongodb service
|
|
|
|
service: name={{ mongodb_daemon_name }} state=restarted
|
2015-06-28 19:54:04 +00:00
|
|
|
when: mongodb_manage_service
|
|
|
|
|
2015-11-22 09:58:35 +00:00
|
|
|
- name: wait MongoDB port is listening
|
2016-04-17 13:43:00 +00:00
|
|
|
wait_for: host="{{ mongodb_net_bindip }}" port="{{ mongodb_net_port }}" delay=5 state=started
|
2015-11-22 09:58:35 +00:00
|
|
|
|
2015-06-28 19:54:04 +00:00
|
|
|
- name: stop mongodb if was not started
|
|
|
|
shell: "kill {{ pidof_mongod.stdout }}"
|
|
|
|
when: mongodb_manage_service == false and pidof_mongod.rc == 0
|