mirror of
https://github.com/status-im/ansible-role-mongodb.git
synced 2025-01-12 22:44:27 +00:00
Added authorization configuration
This commit is contained in:
parent
5f167f612a
commit
9e17ec9ed8
@ -76,3 +76,7 @@ mongodb_keyfile_content: |
|
||||
ZWLnP/mXKV992/Jhu0Z577DHlh+3JIYx0PceB9yzACJ8MNARHF7QpBkhtuGMGZpF
|
||||
T+c73exupZFxItXs1Bnhe3djgE3MKKyYvxNUIbcTJoe7nhVMrwO/7lBSpVLvC4p3
|
||||
wR700U0LDaGGQpslGtiE56SemgoP
|
||||
|
||||
# password for administrative users
|
||||
mongodb_user_admin_password: passw0rd
|
||||
mongodb_root_admin_password: passw0rd
|
||||
|
47
tasks/authorization.yml
Normal file
47
tasks/authorization.yml
Normal file
@ -0,0 +1,47 @@
|
||||
---
|
||||
|
||||
- name: Install required package for mongodb_user module
|
||||
apt: name=python-pymongo
|
||||
|
||||
- name: create administrative user siteRootAdmin
|
||||
mongodb_user:
|
||||
database: admin
|
||||
name: "{{ item.name }}"
|
||||
password: "{{ item.password }}"
|
||||
roles: "{{ item.roles }}"
|
||||
login_host: "{{ mongodb_user_login_host|default('localhost') }}"
|
||||
with_items:
|
||||
- {
|
||||
name: siteRootAdmin,
|
||||
password: "{{ mongodb_root_admin_password }}",
|
||||
roles: "root"
|
||||
}
|
||||
|
||||
- name: create administrative user siteUserAdmin
|
||||
mongodb_user:
|
||||
database: admin
|
||||
name: "{{ item.name }}"
|
||||
password: "{{ item.password }}"
|
||||
roles: "{{ item.roles }}"
|
||||
login_host: "{{ mongodb_user_login_host|default('localhost') }}"
|
||||
login_user: "siteRootAdmin"
|
||||
login_password: "{{ mongodb_root_admin_password }}"
|
||||
with_items:
|
||||
- {
|
||||
name: siteUserAdmin,
|
||||
password: "{{ mongodb_user_admin_password }}",
|
||||
roles: "userAdminAnyDatabase"
|
||||
}
|
||||
|
||||
- name: create normal users
|
||||
mongodb_user:
|
||||
database: "{{ item.database }}"
|
||||
name: "{{ item.name }}"
|
||||
password: "{{ item.password }}"
|
||||
roles: "{{ item.roles }}"
|
||||
login_host: "{{ mongodb_user_login_host|default('localhost') }}"
|
||||
login_user: "siteRootAdmin"
|
||||
login_password: "{{ mongodb_root_admin_password }}"
|
||||
with_items:
|
||||
- {{ mongodb_users }}
|
||||
when: mongodb_users is defined
|
@ -9,5 +9,8 @@
|
||||
service: name={{ mongodb_daemon_name }} state=started enabled=yes
|
||||
changed_when: False
|
||||
|
||||
- include: authorization.yml
|
||||
when: mongodb_conf_auth == "yes"
|
||||
|
||||
- include: mms-agent.yml
|
||||
when: mongodb_mms_api_key != ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user