xoxys.mongodb/tasks/auth.yml
2018-07-07 18:59:07 +02:00

46 lines
936 B
YAML

---
- block:
- name: Backup current config file
copy:
src: /etc/mongod.conf
dest: /etc/mongod.conf.bak
remote_src: True
changed_when: False
- name: Deploy config file without auth
template:
src: etc/mongod_init.conf.j2
dest: /etc/mongod.conf
mode: 0644
changed_when: False
- name: Restart service
service:
name: mongod
state: restarted
changed_when: False
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
- name: Restart service
service:
name: mongod
state: restarted
changed_when: False
become: True