|
9 | 9 | name: "{{ item.name }}"
|
10 | 10 | password: "{{ item.password }}"
|
11 | 11 | roles: "{{ item.roles }}"
|
12 |
| - login_host: 127.0.0.1 |
| 12 | + login_host: "{{ mongodb_listen_ip }}" |
13 | 13 | with_items:
|
14 | 14 | - {
|
15 | 15 | name: "{{ mongodb_user_admin_name }}",
|
|
25 | 25 | name: "{{ item.name }}"
|
26 | 26 | password: "{{ item.password }}"
|
27 | 27 | roles: "{{ item.roles }}"
|
28 |
| - login_host: 127.0.0.1 |
| 28 | + login_host: "{{ mongodb_listen_ip }}" |
29 | 29 | login_user: "{{ mongodb_user_admin_name }}"
|
30 | 30 | login_password: "{{ mongodb_user_admin_password }}"
|
31 | 31 | with_items:
|
|
44 | 44 | password: "{{ item.password }}"
|
45 | 45 | roles: "{{ item.roles }}"
|
46 | 46 | replica_set: "{{ mongodb_conf_replSet }}"
|
47 |
| - login_host: 127.0.0.1 |
| 47 | + login_host: "{{ mongodb_listen_ip }}" |
48 | 48 | login_user: "{{ mongodb_user_admin_name }}"
|
49 | 49 | login_password: "{{ mongodb_user_admin_password }}"
|
50 | 50 | with_items:
|
51 | 51 | - "{{ mongodb_users }}"
|
52 | 52 | when: mongodb_users is defined and ansible_local.mongodb.mongodb.mongodb_login_port is undefined
|
53 | 53 |
|
54 | 54 | - name: Create facts.d directory
|
55 |
| - file: |
56 |
| - state: directory |
57 |
| - recurse: yes |
58 |
| - path: /etc/ansible/facts.d |
59 |
| - when: rootadmin_user_result|changed or useradmin_user_result|changed |
| 55 | + file: path=/etc/ansible/facts.d state=directory recurse=yes |
| 56 | + when: (ansible_local.mongodb.mongodb.mongodb_login_port is undefined) and (rootadmin_user_result|changed or useradmin_user_result|changed or config_result|changed) |
60 | 57 |
|
61 | 58 | - name: Create facts file for mongodb
|
62 |
| - copy: |
63 |
| - dest: /etc/ansible/facts.d/mongodb.fact |
64 |
| - content: "[mongodb]\nmongodb_login_port={{ mongodb_conf_port }}\n\n" |
65 |
| - when: rootadmin_user_result|changed or useradmin_user_result|changed |
| 59 | + template: src=mongodb.fact.j2 dest=/etc/ansible/facts.d/mongodb.fact |
| 60 | + when: (ansible_local.mongodb.mongodb.mongodb_login_port is undefined) and (rootadmin_user_result|changed or useradmin_user_result|changed or config_result|changed) |
| 61 | + |
0 commit comments