|
1 | 1 | ---
|
2 | 2 |
|
| 3 | +- name: Check value of variable mongodb_net_ssl_host |
| 4 | + fail: |
| 5 | + msg: 'Set mongodb_net_ssl_mode is preferSSL or set valid hostname for mongodb_net_ssl_host!' |
| 6 | + when: ( mongodb_net_ssl_mode == 'requireSSL' |
| 7 | + and mongodb_net_ssl_host == '' ) |
| 8 | + |
| 9 | +- name: Check value of variable mongodb_login_host |
| 10 | + fail: |
| 11 | + msg: 'Set mongodb_login_host equal mongodb_net_ssl_host!' |
| 12 | + when: ( mongodb_net_ssl_mode == 'requireSSL' |
| 13 | + and mongodb_net_ssl_host != mongodb_login_host |
| 14 | + and not mongodb_replication_replset ) |
| 15 | + |
3 | 16 | - name: Include OS-specific variables
|
4 | 17 | include_vars: "{{ item }}"
|
5 | 18 | with_first_found:
|
|
32 | 45 |
|
33 | 46 | - name: Check where admin user already exists
|
34 | 47 | command: >
|
35 |
| - mongo --quiet -u {{ mongodb_user_admin_name }} \ |
| 48 | + mongo --quiet {{ '--ssl --host ' + mongodb_net_ssl_host if mongodb_net_ssl_mode == 'requireSSL' else '' }} -u {{ mongodb_user_admin_name }} \ |
36 | 49 | -p {{ mongodb_user_admin_password }} --port {{ mongodb_net_port }} --eval 'db.version()' admin
|
37 | 50 | register: mongodb_user_admin_check
|
38 | 51 | changed_when: false
|
|
61 | 74 | login_password: "{{ mongodb_user_admin_password }}"
|
62 | 75 | login_port: "{{ mongodb_login_port|default(27017) }}"
|
63 | 76 | login_host: "{{ mongodb_login_host|default('localhost') }}"
|
| 77 | + ssl: "{{ True if mongodb_net_ssl_mode == 'requireSSL' else False }}" |
64 | 78 | with_items:
|
65 | 79 | - "{{ mongodb_users | default([]) }}"
|
66 | 80 | when: ( mongodb_replication_replset
|
|
79 | 93 | login_user: "{{ mongodb_user_admin_name }}"
|
80 | 94 | login_password: "{{ mongodb_user_admin_password }}"
|
81 | 95 | login_port: "{{ mongodb_net_port }}"
|
| 96 | + login_host: "{{ mongodb_login_host|default('localhost') }}" |
| 97 | + ssl: "{{ True if mongodb_net_ssl_mode == 'requireSSL' else False }}" |
82 | 98 | with_items:
|
83 | 99 | - "{{ mongodb_users | default([]) }}"
|
84 | 100 | when: ( mongodb_security_authorization == 'enabled'
|
|
99 | 115 | login_password: "{{ mongodb_user_admin_password }}"
|
100 | 116 | login_port: "{{ mongodb_login_port|default(27017) }}"
|
101 | 117 | login_host: "{{ mongodb_login_host|default('localhost') }}"
|
| 118 | + ssl: "{{ True if mongodb_net_ssl_mode == 'requireSSL' else False }}" |
102 | 119 | with_items:
|
103 | 120 | - "{{ mongodb_oplog_users | default([]) }}"
|
104 | 121 | when: ( mongodb_replication_replset | length > 0
|
|
0 commit comments