mongodb_force_wait_for_port config var; mongodb_listen_iface renamed to mongodb_listen_ip; facts via a template
This commit is contained in:
parent
84b9f87e56
commit
a8e9ad8d0e
|
@ -0,0 +1 @@
|
|||
.idea
|
|
@ -12,6 +12,7 @@ Ansible role which manage [MongoDB](http://www.mongodb.org/)
|
|||
```yaml
|
||||
mongodb_package: mongodb-org
|
||||
|
||||
mongodb_force_wait_for_port: false # When not forced, the role will wait for mongod port to become available only with systemd
|
||||
mongodb_additional_packages:
|
||||
- python-pymongo
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
|
||||
mongodb_package: mongodb-org
|
||||
mongodb_force_wait_for_port: false
|
||||
|
||||
mongodb_additional_packages:
|
||||
- python-pymongo
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
name: "{{ item.name }}"
|
||||
password: "{{ item.password }}"
|
||||
roles: "{{ item.roles }}"
|
||||
login_host: "{{ mongodb_listen_iface }}"
|
||||
login_host: "{{ mongodb_listen_ip }}"
|
||||
with_items:
|
||||
- {
|
||||
name: "{{ mongodb_user_admin_name }}",
|
||||
|
@ -25,7 +25,7 @@
|
|||
name: "{{ item.name }}"
|
||||
password: "{{ item.password }}"
|
||||
roles: "{{ item.roles }}"
|
||||
login_host: "{{ mongodb_listen_iface }}"
|
||||
login_host: "{{ mongodb_listen_ip }}"
|
||||
login_user: "{{ mongodb_user_admin_name }}"
|
||||
login_password: "{{ mongodb_user_admin_password }}"
|
||||
with_items:
|
||||
|
@ -44,7 +44,7 @@
|
|||
password: "{{ item.password }}"
|
||||
roles: "{{ item.roles }}"
|
||||
replica_set: "{{ mongodb_conf_replSet }}"
|
||||
login_host: "{{ mongodb_listen_iface }}"
|
||||
login_host: "{{ mongodb_listen_ip }}"
|
||||
login_user: "{{ mongodb_user_admin_name }}"
|
||||
login_password: "{{ mongodb_user_admin_password }}"
|
||||
with_items:
|
||||
|
@ -52,15 +52,10 @@
|
|||
when: mongodb_users is defined and ansible_local.mongodb.mongodb.mongodb_login_port is undefined
|
||||
|
||||
- name: Create facts.d directory
|
||||
file:
|
||||
state: directory
|
||||
recurse: yes
|
||||
path: /etc/ansible/facts.d
|
||||
file: path=/etc/ansible/facts.d state=directory recurse=yes
|
||||
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
|
||||
copy:
|
||||
dest: /etc/ansible/facts.d/mongodb.fact
|
||||
content: "[mongodb]\nmongodb_login_port={{ mongodb_conf_port }}\nmongodb_listen_iface={{ mongodb_conf_bind_ip }}\n"
|
||||
template: src=mongodb.fact.j2 dest=/etc/ansible/facts.d/mongodb.fact
|
||||
when: (ansible_local.mongodb.mongodb.mongodb_login_port is undefined) and (rootadmin_user_result|changed or useradmin_user_result|changed or config_result|changed)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
name: "{{ item.name }}"
|
||||
password: "{{ item.password }}"
|
||||
roles: "{{ item.roles }}"
|
||||
login_host: "{{ mongodb_listen_iface }}"
|
||||
login_host: "{{ mongodb_listen_ip }}"
|
||||
login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}"
|
||||
with_items:
|
||||
- {
|
||||
|
@ -20,7 +20,7 @@
|
|||
name: "{{ item.name }}"
|
||||
password: "{{ item.password }}"
|
||||
roles: "{{ item.roles }}"
|
||||
login_host: "{{ mongodb_listen_iface }}"
|
||||
login_host: "{{ mongodb_listen_ip }}"
|
||||
login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}"
|
||||
login_user: "{{ mongodb_user_admin_name }}"
|
||||
login_password: "{{ mongodb_user_admin_password }}"
|
||||
|
@ -38,7 +38,7 @@
|
|||
password: "{{ item.password }}"
|
||||
roles: "{{ item.roles }}"
|
||||
replica_set: "{{ mongodb_conf_replSet }}"
|
||||
login_host: "{{ mongodb_listen_iface }}"
|
||||
login_host: "{{ mongodb_listen_ip }}"
|
||||
login_port: "{{ ansible_local.mongodb.mongodb.mongodb_login_port }}"
|
||||
login_user: "{{ mongodb_user_admin_name }}"
|
||||
login_password: "{{ mongodb_user_admin_password }}"
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
---
|
||||
- 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 default MongoDB listen IP
|
||||
set_fact: mongodb_listen_ip=127.0.0.1
|
||||
when: ansible_local.mongodb.mongodb.mongodb_listen_ip 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: Register MongoDB listen IP
|
||||
set_fact: mongodb_listen_ip={{ ansible_local.mongodb.mongodb.mongodb_listen_ip }}
|
||||
when: ansible_local.mongodb.mongodb.mongodb_listen_ip is defined
|
||||
|
||||
|
||||
- name: Create keyFile
|
||||
|
@ -25,8 +25,8 @@
|
|||
service: name={{ mongodb_daemon_name }} state=started enabled=yes
|
||||
|
||||
- name: wait MongoDB port is listening
|
||||
wait_for: host="{{ mongodb_listen_iface }}" port="{{ mongodb_conf_port }}" delay=5 timeout=60 state=started
|
||||
#when: "'systemd' in systemd.stdout" #TODO Why only with systemd?
|
||||
wait_for: host="{{ mongodb_listen_ip }}" port="{{ mongodb_conf_port }}" delay=10 timeout=60 state=started
|
||||
when: mongodb_force_wait_for_port or "'systemd' in systemd.stdout"
|
||||
|
||||
- include: auth_initialization.yml
|
||||
when: mongodb_conf_auth
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[mongodb]
|
||||
mongodb_login_port={{ mongodb_conf_port }}
|
||||
mongodb_listen_ip={{ mongodb_conf_bind_ip }}
|
Loading…
Reference in New Issue