Configuration and authentication with custom settings fix
This commit is contained in:
parent
60ec8021ee
commit
84b9f87e56
|
@ -9,7 +9,7 @@
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
password: "{{ item.password }}"
|
password: "{{ item.password }}"
|
||||||
roles: "{{ item.roles }}"
|
roles: "{{ item.roles }}"
|
||||||
login_host: 127.0.0.1
|
login_host: "{{ mongodb_listen_iface }}"
|
||||||
with_items:
|
with_items:
|
||||||
- {
|
- {
|
||||||
name: "{{ mongodb_user_admin_name }}",
|
name: "{{ mongodb_user_admin_name }}",
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
password: "{{ item.password }}"
|
password: "{{ item.password }}"
|
||||||
roles: "{{ item.roles }}"
|
roles: "{{ item.roles }}"
|
||||||
login_host: 127.0.0.1
|
login_host: "{{ mongodb_listen_iface }}"
|
||||||
login_user: "{{ mongodb_user_admin_name }}"
|
login_user: "{{ mongodb_user_admin_name }}"
|
||||||
login_password: "{{ mongodb_user_admin_password }}"
|
login_password: "{{ mongodb_user_admin_password }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
password: "{{ item.password }}"
|
password: "{{ item.password }}"
|
||||||
roles: "{{ item.roles }}"
|
roles: "{{ item.roles }}"
|
||||||
replica_set: "{{ mongodb_conf_replSet }}"
|
replica_set: "{{ mongodb_conf_replSet }}"
|
||||||
login_host: 127.0.0.1
|
login_host: "{{ mongodb_listen_iface }}"
|
||||||
login_user: "{{ mongodb_user_admin_name }}"
|
login_user: "{{ mongodb_user_admin_name }}"
|
||||||
login_password: "{{ mongodb_user_admin_password }}"
|
login_password: "{{ mongodb_user_admin_password }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
@ -56,10 +56,11 @@
|
||||||
state: directory
|
state: directory
|
||||||
recurse: yes
|
recurse: yes
|
||||||
path: /etc/ansible/facts.d
|
path: /etc/ansible/facts.d
|
||||||
when: rootadmin_user_result|changed or useradmin_user_result|changed
|
when: (ansible_local.mongodb.mongodb.mongodb_login_port is undefined) and (rootadmin_user_result|changed or useradmin_user_result|changed or config_result|changed)
|
||||||
|
|
||||||
- name: Create facts file for mongodb
|
- name: Create facts file for mongodb
|
||||||
copy:
|
copy:
|
||||||
dest: /etc/ansible/facts.d/mongodb.fact
|
dest: /etc/ansible/facts.d/mongodb.fact
|
||||||
content: "[mongodb]\nmongodb_login_port={{ mongodb_conf_port }}\n\n"
|
content: "[mongodb]\nmongodb_login_port={{ mongodb_conf_port }}\nmongodb_listen_iface={{ mongodb_conf_bind_ip }}\n"
|
||||||
when: rootadmin_user_result|changed or useradmin_user_result|changed
|
when: (ansible_local.mongodb.mongodb.mongodb_login_port is undefined) and (rootadmin_user_result|changed or useradmin_user_result|changed or config_result|changed)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
---
|
||||||
- name: create administrative user siteUserAdmin port=yes
|
- name: create administrative user siteUserAdmin port=yes
|
||||||
mongodb_user:
|
mongodb_user:
|
||||||
database: admin
|
database: admin
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
password: "{{ item.password }}"
|
password: "{{ item.password }}"
|
||||||
roles: "{{ item.roles }}"
|
roles: "{{ item.roles }}"
|
||||||
login_host: 127.0.0.1
|
login_host: "{{ mongodb_listen_iface }}"
|
||||||
login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}"
|
login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}"
|
||||||
with_items:
|
with_items:
|
||||||
- {
|
- {
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
password: "{{ item.password }}"
|
password: "{{ item.password }}"
|
||||||
roles: "{{ item.roles }}"
|
roles: "{{ item.roles }}"
|
||||||
login_host: 127.0.0.1
|
login_host: "{{ mongodb_listen_iface }}"
|
||||||
login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}"
|
login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}"
|
||||||
login_user: "{{ mongodb_user_admin_name }}"
|
login_user: "{{ mongodb_user_admin_name }}"
|
||||||
login_password: "{{ mongodb_user_admin_password }}"
|
login_password: "{{ mongodb_user_admin_password }}"
|
||||||
|
@ -30,14 +31,14 @@
|
||||||
roles: "root"
|
roles: "root"
|
||||||
}
|
}
|
||||||
|
|
||||||
- name: create normal users
|
- name: create normal users port=yes
|
||||||
mongodb_user:
|
mongodb_user:
|
||||||
database: "{{ item.database }}"
|
database: "{{ item.database }}"
|
||||||
name: "{{ item.name }}"
|
name: "{{ item.name }}"
|
||||||
password: "{{ item.password }}"
|
password: "{{ item.password }}"
|
||||||
roles: "{{ item.roles }}"
|
roles: "{{ item.roles }}"
|
||||||
replica_set: "{{ mongodb_conf_replSet }}"
|
replica_set: "{{ mongodb_conf_replSet }}"
|
||||||
login_host: 127.0.0.1
|
login_host: "{{ mongodb_listen_iface }}"
|
||||||
login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}"
|
login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}"
|
||||||
login_user: "{{ mongodb_user_admin_name }}"
|
login_user: "{{ mongodb_user_admin_name }}"
|
||||||
login_password: "{{ mongodb_user_admin_password }}"
|
login_password: "{{ mongodb_user_admin_password }}"
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
---
|
---
|
||||||
|
- name: Register default MongoDB listen interface
|
||||||
|
set_fact: mongodb_listen_iface=127.0.0.1
|
||||||
|
when: ansible_local.mongodb.mongodb.mongodb_listen_iface is undefined
|
||||||
|
|
||||||
|
- name: Register MongoDB listen interface
|
||||||
|
set_fact: mongodb_listen_iface={{ ansible_local.mongodb.mongodb.mongodb_listen_iface }}
|
||||||
|
when: ansible_local.mongodb.mongodb.mongodb_listen_iface is defined
|
||||||
|
|
||||||
|
|
||||||
- name: Create keyFile
|
- name: Create keyFile
|
||||||
copy:
|
copy:
|
||||||
|
@ -17,8 +25,8 @@
|
||||||
service: name={{ mongodb_daemon_name }} state=started enabled=yes
|
service: name={{ mongodb_daemon_name }} state=started enabled=yes
|
||||||
|
|
||||||
- name: wait MongoDB port is listening
|
- name: wait MongoDB port is listening
|
||||||
wait_for: host="{{ mongodb_conf_bind_ip }}"port="{{ mongodb_conf_port }}" delay=10 timeout=60 state=started
|
wait_for: host="{{ mongodb_listen_iface }}" port="{{ mongodb_conf_port }}" delay=5 timeout=60 state=started
|
||||||
when: "'systemd' in systemd.stdout"
|
#when: "'systemd' in systemd.stdout" #TODO Why only with systemd?
|
||||||
|
|
||||||
- include: auth_initialization.yml
|
- include: auth_initialization.yml
|
||||||
when: mongodb_conf_auth
|
when: mongodb_conf_auth
|
||||||
|
@ -29,11 +37,17 @@
|
||||||
- name: Configure database directory
|
- name: Configure database directory
|
||||||
file: state=directory path={{ mongodb_conf_dbpath }} owner={{mongodb_user}} group={{mongodb_user}} mode=0755
|
file: state=directory path={{ mongodb_conf_dbpath }} owner={{mongodb_user}} group={{mongodb_user}} mode=0755
|
||||||
|
|
||||||
- name: Configure logs
|
- name: Create log dir if missing
|
||||||
file: state=file path={{ mongodb_conf_logpath }} owner={{mongodb_user}} group={{mongodb_user}} mode=0644
|
file: state=directory recurse=yes dest={{ mongodb_conf_logpath|dirname }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755
|
||||||
|
|
||||||
|
- name: Create log if missing
|
||||||
|
file: state=touch dest={{ mongodb_conf_logpath }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755
|
||||||
|
|
||||||
|
- name: Configure log file
|
||||||
|
file: state=file path={{ mongodb_conf_logpath }} owner={{mongodb_user}} group={{mongodb_user}} mode=0755
|
||||||
|
|
||||||
- name: Configure mongodb
|
- name: Configure mongodb
|
||||||
template: src=mongod.conf.j2 dest=/etc/mongod.conf owner=root group=root mode=0644
|
template: src=mongod.conf.j2 dest=/etc/mongod.conf backup=yes owner=root group=root mode=0644
|
||||||
register: config_result
|
register: config_result
|
||||||
|
|
||||||
- name: mongodb restart
|
- name: mongodb restart
|
||||||
|
|
Loading…
Reference in New Issue