|
42 | 42 | and mongodb_user_admin_check.rc != 0 )
|
43 | 43 | tags: [mongodb]
|
44 | 44 |
|
45 |
| -- name: create normal users |
| 45 | +- name: create normal users with replicaset |
46 | 46 | mongodb_user:
|
47 | 47 | database: "{{ item.database }}"
|
48 | 48 | name: "{{ item.name }}"
|
|
51 | 51 | roles: "{{ item.roles }}"
|
52 | 52 | login_user: "{{ mongodb_user_admin_name }}"
|
53 | 53 | login_password: "{{ mongodb_user_admin_password }}"
|
54 |
| - login_port: "{{ mongodb_net_port }}" |
55 |
| - login_database: "admin" |
| 54 | + login_port: "{{ mongodb_login_port|default(27017) }}" |
| 55 | + login_host: "{{ mongodb_login_host|default('localhost') }}" |
56 | 56 | with_items:
|
57 | 57 | - "{{ mongodb_users | default([]) }}"
|
58 |
| - when: mongodb_security_authorization == 'enabled' |
| 58 | + when: ( mongodb_replication_replset |
| 59 | + and mongodb_replication_replset != '' |
| 60 | + and mongodb_security_authorization == 'enabled' |
| 61 | + and mongodb_master is defined and mongodb_master ) |
59 | 62 | tags: [mongodb]
|
60 | 63 |
|
| 64 | +- name: create normal users without replicaset |
| 65 | + mongodb_user: |
| 66 | + database: "{{ item.database }}" |
| 67 | + name: "{{ item.name }}" |
| 68 | + password: "{{ item.password }}" |
| 69 | + update_password: "{{ mongodb_user_update_password }}" |
| 70 | + roles: "{{ item.roles }}" |
| 71 | + login_user: "{{ mongodb_user_admin_name }}" |
| 72 | + login_password: "{{ mongodb_user_admin_password }}" |
| 73 | + login_port: "{{ mongodb_net_port }}" |
| 74 | + with_items: |
| 75 | + - "{{ mongodb_users | default([]) }}" |
| 76 | + when: ( mongodb_security_authorization == 'enabled' |
| 77 | + and (not mongodb_replication_replset |
| 78 | + or mongodb_replication_replset == '') ) |
| 79 | + tags: [mongodb] |
61 | 80 |
|
62 | 81 | - name: Include MMS Agent configuration
|
63 | 82 | include: mms-agent.yml
|
|
0 commit comments