2014-06-04 15:03:58 +00:00
|
|
|
---
|
|
|
|
|
2016-04-27 04:45:25 +00:00
|
|
|
- name: Include OS-specific variables
|
|
|
|
include_vars: "{{ item }}"
|
|
|
|
with_first_found:
|
2018-02-22 17:43:04 +00:00
|
|
|
- "{{ ansible_distribution_release }}.yml"
|
2016-04-27 04:45:25 +00:00
|
|
|
- "{{ ansible_distribution }}.yml"
|
|
|
|
- "{{ ansible_os_family }}.yml"
|
|
|
|
|
2018-02-22 17:43:04 +00:00
|
|
|
- name: Include installation tasks
|
2018-02-20 18:23:43 +00:00
|
|
|
include: "install.{{ ansible_os_family | lower }}.yml"
|
2015-03-04 10:05:08 +00:00
|
|
|
tags: [mongodb]
|
2015-02-17 09:01:36 +00:00
|
|
|
|
2016-04-17 13:43:00 +00:00
|
|
|
- name: Include configuration.yml
|
2018-02-20 18:23:43 +00:00
|
|
|
include: configure.yml
|
2015-03-04 10:05:08 +00:00
|
|
|
tags: [mongodb]
|
2015-02-17 09:01:36 +00:00
|
|
|
|
2016-04-17 13:43:00 +00:00
|
|
|
- name: Include replication and auth configuration
|
2018-02-20 18:23:43 +00:00
|
|
|
include: replication_init_auth.yml
|
2016-04-17 13:43:00 +00:00
|
|
|
when: ( mongodb_replication_replset
|
|
|
|
and mongodb_replication_replset != ''
|
|
|
|
and mongodb_security_authorization == 'enabled'
|
2015-06-22 08:59:25 +00:00
|
|
|
and mongodb_master is defined and mongodb_master )
|
|
|
|
tags: [mongodb]
|
|
|
|
|
2016-04-17 13:43:00 +00:00
|
|
|
- name: Include replication configuration
|
2018-02-20 18:23:43 +00:00
|
|
|
include: replication.yml
|
2016-04-17 13:43:00 +00:00
|
|
|
when: mongodb_replication_replset and mongodb_replication_replset != ''
|
2015-06-22 08:59:25 +00:00
|
|
|
tags: [mongodb]
|
|
|
|
|
2017-09-14 08:56:34 +00:00
|
|
|
- name: Check where admin user already exists
|
2016-04-17 13:43:00 +00:00
|
|
|
command: >
|
|
|
|
mongo --quiet -u {{ mongodb_user_admin_name }} \
|
2017-04-10 06:04:24 +00:00
|
|
|
-p {{ mongodb_user_admin_password }} --port {{ mongodb_net_port }} --eval 'db.version()' admin
|
2016-04-17 13:43:00 +00:00
|
|
|
register: mongodb_user_admin_check
|
|
|
|
changed_when: false
|
2018-02-15 06:14:31 +00:00
|
|
|
check_mode: no
|
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 == '') )
|
2017-09-14 08:56:34 +00:00
|
|
|
no_log: true
|
2015-06-22 08:59:25 +00:00
|
|
|
tags: [mongodb]
|
|
|
|
|
2016-04-17 13:43:00 +00:00
|
|
|
- name: Include authorization configuration
|
2018-02-20 18:23:43 +00:00
|
|
|
include: auth_initialization.yml
|
2016-04-17 13:43:00 +00:00
|
|
|
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
|
2018-02-20 18:23:43 +00:00
|
|
|
mongodb_user_fixed:
|
2016-04-17 13:43:00 +00:00
|
|
|
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 )
|
2016-09-21 21:51:38 +00:00
|
|
|
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
|
2018-02-20 18:23:43 +00:00
|
|
|
mongodb_user_fixed:
|
2016-04-17 17:18:31 +00:00
|
|
|
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 == '') )
|
2016-09-21 21:51:38 +00:00
|
|
|
no_log: true
|
2016-04-17 17:18:31 +00:00
|
|
|
tags: [mongodb]
|
2016-04-17 13:43:00 +00:00
|
|
|
|
2018-09-03 20:06:22 +00:00
|
|
|
- name: create oplog user with replicaset
|
|
|
|
mongodb_user_fixed:
|
|
|
|
database: admin
|
|
|
|
user: "{{ item.user }}"
|
|
|
|
password: "{{ item.password }}"
|
|
|
|
update_password: "{{ mongodb_user_update_password }}"
|
|
|
|
roles:
|
|
|
|
- db: local
|
|
|
|
role: read
|
|
|
|
login_user: "{{ mongodb_user_admin_name }}"
|
|
|
|
login_password: "{{ mongodb_user_admin_password }}"
|
|
|
|
login_port: "{{ mongodb_login_port|default(27017) }}"
|
|
|
|
login_host: "{{ mongodb_login_host|default('localhost') }}"
|
|
|
|
with_items:
|
|
|
|
- "{{ mongodb_oplog_users | default([]) }}"
|
|
|
|
when: ( mongodb_replication_replset
|
|
|
|
and mongodb_replication_replset != ''
|
|
|
|
and mongodb_security_authorization == 'enabled'
|
|
|
|
and mongodb_master is defined and mongodb_master )
|
|
|
|
no_log: false
|
|
|
|
tags: [mongodb]
|
|
|
|
|
2016-04-17 13:43:00 +00:00
|
|
|
- name: Include MMS Agent configuration
|
2018-02-20 18:23:43 +00:00
|
|
|
include: mms-agent.yml
|
2015-02-17 09:01:36 +00:00
|
|
|
when: mongodb_mms_api_key != ""
|
2015-03-04 10:05:08 +00:00
|
|
|
tags: [mongodb]
|