ansible-role-mongodb/tasks/main.yml

89 lines
2.9 KiB
YAML
Raw Normal View History

2014-06-04 15:03:58 +00:00
---
2016-04-17 13:43:00 +00:00
- name: Include installation on Debian-based OS
include: install.deb.yml
2015-02-17 09:01:36 +00:00
when: ansible_os_family == 'Debian'
tags: [mongodb]
2015-02-17 09:01:36 +00:00
2016-04-17 13:43:00 +00:00
- name: Include configuration.yml
include: configure.yml
tags: [mongodb]
2015-02-17 09:01:36 +00:00
2016-04-17 13:43:00 +00:00
- name: Include replication and auth configuration
include: replication_init_auth.yml
when: ( mongodb_replication_replset
and mongodb_replication_replset != ''
and mongodb_security_authorization == 'enabled'
and mongodb_master is defined and mongodb_master )
tags: [mongodb]
2016-04-17 13:43:00 +00:00
- name: Include replication configuration
include: replication.yml
when: mongodb_replication_replset and mongodb_replication_replset != ''
tags: [mongodb]
2016-04-17 13:43:00 +00:00
- name: Check user admin is exists
command: >
mongo --quiet -u {{ mongodb_user_admin_name }} \
-p {{ mongodb_user_admin_password }} --eval 'db.version()' admin
register: mongodb_user_admin_check
changed_when: false
always_run: yes # side-effect free, so it can be run in check-mode as well
2016-04-17 13:43:00 +00:00
ignore_errors: true
when: ( mongodb_security_authorization == 'enabled'
and (not mongodb_replication_replset
or mongodb_replication_replset == '') )
no_log: true
tags: [mongodb]
2016-04-17 13:43:00 +00:00
- name: Include authorization configuration
include: auth_initialization.yml
when: ( mongodb_security_authorization == 'enabled'
and (not mongodb_replication_replset
or mongodb_replication_replset == '')
and mongodb_user_admin_check.rc != 0 )
tags: [mongodb]
2016-04-17 17:18:31 +00:00
- name: create normal users with replicaset
2016-04-17 13:43:00 +00:00
mongodb_user:
database: "{{ item.database }}"
name: "{{ item.name }}"
password: "{{ item.password }}"
update_password: "{{ mongodb_user_update_password }}"
roles: "{{ item.roles }}"
login_user: "{{ mongodb_user_admin_name }}"
login_password: "{{ mongodb_user_admin_password }}"
2016-04-17 17:18:31 +00:00
login_port: "{{ mongodb_login_port|default(27017) }}"
login_host: "{{ mongodb_login_host|default('localhost') }}"
2016-04-17 13:43:00 +00:00
with_items:
- "{{ mongodb_users | default([]) }}"
2016-04-17 17:18:31 +00:00
when: ( mongodb_replication_replset
and mongodb_replication_replset != ''
and mongodb_security_authorization == 'enabled'
and mongodb_master is defined and mongodb_master )
no_log: true
2016-04-17 13:43:00 +00:00
tags: [mongodb]
2016-04-17 17:18:31 +00:00
- name: create normal users without replicaset
mongodb_user:
database: "{{ item.database }}"
name: "{{ item.name }}"
password: "{{ item.password }}"
update_password: "{{ mongodb_user_update_password }}"
roles: "{{ item.roles }}"
login_user: "{{ mongodb_user_admin_name }}"
login_password: "{{ mongodb_user_admin_password }}"
login_port: "{{ mongodb_net_port }}"
with_items:
- "{{ mongodb_users | default([]) }}"
when: ( mongodb_security_authorization == 'enabled'
and (not mongodb_replication_replset
or mongodb_replication_replset == '') )
no_log: true
2016-04-17 17:18:31 +00:00
tags: [mongodb]
2016-04-17 13:43:00 +00:00
- name: Include MMS Agent configuration
include: mms-agent.yml
2015-02-17 09:01:36 +00:00
when: mongodb_mms_api_key != ""
tags: [mongodb]