xoxys.mongodb/tasks/auth.yml

46 lines
936 B
YAML
Raw Normal View History

2018-07-07 16:53:03 +00:00
---
- block:
- name: Backup current config file
copy:
src: /etc/mongod.conf
dest: /etc/mongod.conf.bak
remote_src: True
changed_when: False
2018-07-07 16:53:03 +00:00
- name: Deploy config file without auth
template:
src: etc/mongod_init.conf.j2
dest: /etc/mongod.conf
mode: 0644
changed_when: False
2018-07-07 16:53:03 +00:00
- name: Restart service
service:
name: mongod
2018-07-07 16:59:07 +00:00
state: restarted
changed_when: False
2018-07-07 16:53:03 +00:00
become: True
- name: Create admin user
mongodb_user:
database: admin
name: "{{ mongodb_user_admin_name }}"
password: "{{ mongodb_user_admin_password }}"
roles: readWriteAnyDatabase
state: present
- block:
- name: Restore config file
copy:
src: /etc/mongod.conf.bak
dest: /etc/mongod.conf
remote_src: True
changed_when: False
2018-07-07 16:53:03 +00:00
- name: Restart service
service:
name: mongod
2018-07-07 16:59:07 +00:00
state: restarted
changed_when: False
2018-07-07 16:53:03 +00:00
become: True