xoxys.mongodb/tasks/auth.yml
Robert Kaussow a3880a4698
Some checks failed
continuous-integration/drone/push Build is failing
fix ansible guideine errors
2019-01-12 14:40:16 +01:00

48 lines
1.0 KiB
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 to disable auth
service:
name: mongod
state: restarted
changed_when: False
become: True
become_user: root
- 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 to re-enable auth
service:
name: mongod
state: restarted
changed_when: False
become: True
become_user: root