Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,10 @@ mongodb_logrotate_options:
- dateext
- rotate 7
- size 10M

mongodb_users:
- name: mongo_user
password: password
role: readWrite
databases:
- sample_database
12 changes: 12 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,15 @@
- name: Run mongoshell commands
command: mongo {{ item.key }} --eval "{{ item.value|join('\n') }}"
with_dict: "{{mongodb_shell}}"

- name: Create necesary users with access to databases
mongodb_user:
name: "{{ item.0.name }}"
password: "{{ item.0.password }}"
database: "{{ item.1 }}"
state: present
roles:
- { db: "{{ item.1 }}", role: "{{ item.0.role }}" }
with_subelements:
- "{{ mongodb_users }}"
- databases