| 1 |
- name: Ensure proxy admin password has been set |
| 2 |
na_santricity_auth: |
| 3 |
ssid: proxy |
| 4 |
api_url: "{{ item['key'] }}" |
| 5 |
api_username: "{{ item['value']['proxy_username'] }}" |
| 6 |
api_password: "{{ item['value']['current_proxy_password'] }}" |
| 7 |
validate_certs: "{{ item['value']['proxy_validate_certs'] }}" |
| 8 |
user: admin |
| 9 |
password: "{{ item['value']['proxy_password'] }}" |
| 10 |
minimum_password_length: "{{ item['value']['proxy_minimum_password_length'] }}" |
| 11 |
connection: local |
| 12 |
loop: "{{ lookup('dict', proxy_admin, wantlist=True) }}" |
| 13 |
no_log: true |
| 14 |
vars: |
| 15 |
proxy_admin: |- |
| 16 |
{#- Build a dictionary of all inventoried proxies keyed by their api url #} |
| 17 |
{%- set systems = {} %} |
| 18 |
{%- for array in ansible_play_hosts_all %} |
| 19 |
{%- if "eseries_proxy_api_url" in hostvars[array] and "eseries_proxy_api_password" in hostvars[array] %} |
| 20 |
{%- if systems.update({hostvars[array]["eseries_proxy_api_url"]: { |
| 21 |
"proxy_username": hostvars[array]["eseries_proxy_api_username"] | default('admin'), |
| 22 |
"proxy_password": hostvars[array]["eseries_proxy_api_password"], |
| 23 |
"current_proxy_password": hostvars[array]["eseries_proxy_api_old_password"] | default(hostvars[array]["eseries_proxy_api_password"]), |
| 24 |
"proxy_validate_certs": hostvars[array]["eseries_validate_certs"] | default(omit), |
| 25 |
"proxy_minimum_password_length": hostvars[array]["eseries_proxy_minimum_password_length"] | default(omit)}}) %} |
| 26 |
{%- endif %} |
| 27 |
{%- endif %} |
| 28 |
{%- endfor %} |
| 29 |
{{ systems }} |
| 30 |
tags: |
| 31 |
- always |
| 32 |
|
| 33 |
- name: Ensure proxy non-admin passwords have been set |
| 34 |
na_santricity_auth: |
| 35 |
ssid: proxy |
| 36 |
api_url: "{{ item['value']['proxy_url'] }}" |
| 37 |
api_username: "{{ item['value']['proxy_url_username'] }}" |
| 38 |
api_password: "{{ item['value']['proxy_url_password'] }}" |
| 39 |
validate_certs: "{{ item['value']['proxy_validate_certs'] }}" |
| 40 |
user: "{{ item['value']['proxy_username'] }}" |
| 41 |
password: "{{ item['value']['proxy_password'] }}" |
| 42 |
connection: local |
| 43 |
loop: "{{ lookup('dict', proxy_non_admin, wantlist=True) }}" |
| 44 |
no_log: true |
| 45 |
vars: |
| 46 |
proxy_non_admin: |- |
| 47 |
{#- Build a dictionary of all inventoried proxies keyed by their api url containing non-admin usernames/passwords #} |
| 48 |
{%- set systems = {} %} |
| 49 |
{%- for array in ansible_play_hosts_all %} |
| 50 |
{%- if "eseries_proxy_api_url" in hostvars[array] and "eseries_proxy_api_password" in hostvars[array] and |
| 51 |
(("eseries_proxy_monitor_password" in hostvars[array] and hostvars[array]["eseries_proxy_monitor_password"]) or |
| 52 |
("eseries_proxy_security_password" in hostvars[array] and hostvars[array]["eseries_proxy_security_password"]) or |
| 53 |
("eseries_proxy_storage_password" in hostvars[array] and hostvars[array]["eseries_proxy_storage_password"]) or |
| 54 |
("eseries_proxy_support_password" in hostvars[array] and hostvars[array]["eseries_proxy_support_password"])) %} |
| 55 |
{%- if "eseries_proxy_monitor_password" in hostvars[array] and hostvars[array]["eseries_proxy_monitor_password"] and |
| 56 |
systems.update({[hostvars[array]["eseries_proxy_api_url"], 'monitor'] | join("-"): { |
| 57 |
"proxy_url": hostvars[array]["eseries_proxy_api_url"], |
| 58 |
"proxy_url_username": hostvars[array]["eseries_proxy_api_username"] | default('admin'), |
| 59 |
"proxy_url_password": hostvars[array]["eseries_proxy_api_password"], |
| 60 |
"proxy_username": 'monitor', |
| 61 |
"proxy_password": hostvars[array]["eseries_proxy_monitor_password"], |
| 62 |
"proxy_validate_certs": hostvars[array]["eseries_validate_certs"] | default(omit)}}) %} |
| 63 |
{%- endif %} |
| 64 |
{%- if "eseries_proxy_security_password" in hostvars[array] and hostvars[array]["eseries_proxy_security_password"] and |
| 65 |
systems.update({[hostvars[array]["eseries_proxy_api_url"], 'security'] | join("-"): { |
| 66 |
"proxy_url": hostvars[array]["eseries_proxy_api_url"], |
| 67 |
"proxy_url_username": hostvars[array]["eseries_proxy_api_username"] | default('admin'), |
| 68 |
"proxy_url_password": hostvars[array]["eseries_proxy_api_password"], |
| 69 |
"proxy_username": 'security', |
| 70 |
"proxy_password": hostvars[array]["eseries_proxy_security_password"], |
| 71 |
"proxy_validate_certs": hostvars[array]["eseries_validate_certs"] | default(omit)}}) %} |
| 72 |
{%- endif %} |
| 73 |
{%- if "eseries_proxy_storage_password" in hostvars[array] and hostvars[array]["eseries_proxy_storage_password"] and |
| 74 |
systems.update({[hostvars[array]["eseries_proxy_api_url"], 'storage'] | join("-"): { |
| 75 |
"proxy_url": hostvars[array]["eseries_proxy_api_url"], |
| 76 |
"proxy_url_username": hostvars[array]["eseries_proxy_api_username"] | default('admin'), |
| 77 |
"proxy_url_password": hostvars[array]["eseries_proxy_api_password"], |
| 78 |
"proxy_username": 'storage', |
| 79 |
"proxy_password": hostvars[array]["eseries_proxy_storage_password"], |
| 80 |
"proxy_validate_certs": hostvars[array]["eseries_validate_certs"] | default(omit)}}) %} |
| 81 |
{%- endif %} |
| 82 |
{%- if "eseries_proxy_support_password" in hostvars[array] and hostvars[array]["eseries_proxy_support_password"] and |
| 83 |
systems.update({[hostvars[array]["eseries_proxy_api_url"], 'support'] | join("-"): { |
| 84 |
"proxy_url": hostvars[array]["eseries_proxy_api_url"], |
| 85 |
"proxy_url_username": hostvars[array]["eseries_proxy_api_username"] | default('admin'), |
| 86 |
"proxy_url_password": hostvars[array]["eseries_proxy_api_password"], |
| 87 |
"proxy_username": 'support', |
| 88 |
"proxy_password": hostvars[array]["eseries_proxy_support_password"], |
| 89 |
"proxy_validate_certs": hostvars[array]["eseries_validate_certs"] | default(omit)}}) %} |
| 90 |
{%- endif %} |
| 91 |
{%- endif %} |
| 92 |
{%- endfor %} |
| 93 |
{{ systems }} |
| 94 |
|
| 95 |
- name: Ensure proxy client certificates are installed |
| 96 |
na_santricity_client_certificate: |
| 97 |
ssid: proxy |
| 98 |
api_url: "{{ item['key'] }}" |
| 99 |
api_username: "{{ item['value']['proxy_username'] }}" |
| 100 |
api_password: "{{ item['value']['proxy_password'] }}" |
| 101 |
validate_certs: "{{ item['value']['proxy_validate_certs'] }}" |
| 102 |
certificates: "{{ item['value']['certificates'] }}" |
| 103 |
connection: local |
| 104 |
loop: "{{ lookup('dict', proxy_client_certificates, wantlist=True) }}" |
| 105 |
when: item['value']['certificates'] | length > 0 |
| 106 |
no_log: true |
| 107 |
vars: |
| 108 |
proxy_client_certificates: |- |
| 109 |
{#- Build a dictionary of all inventoried proxies keyed by their api url #} |
| 110 |
{%- set systems = {} %} |
| 111 |
{%- for array in ansible_play_hosts_all %} |
| 112 |
{%- if "eseries_proxy_api_url" in hostvars[array] and "eseries_proxy_api_password" in hostvars[array] %} |
| 113 |
{%- set certs = [] -%} |
| 114 |
|
| 115 |
{#- Add common proxy client certificates -#} |
| 116 |
{%- if "eseries_proxy_client_certificate_common_certificates" in (hostvars[array].keys() | list) -%} |
| 117 |
{%- if hostvars[array]["eseries_proxy_client_certificate_common_certificates"] is string -%} |
| 118 |
{%- if certs.append(hostvars[array]["eseries_proxy_client_certificate_common_certificates"]) -%}{%- endif -%} |
| 119 |
{%- elif hostvars[array]["eseries_proxy_client_certificate_common_certificates"] is iterable -%} |
| 120 |
{%- if certs.extend(hostvars[array]["eseries_proxy_client_certificate_common_certificates"]) -%}{%- endif -%} |
| 121 |
{%- endif -%} |
| 122 |
{%- endif -%} |
| 123 |
|
| 124 |
{#- Add proxy specific client certificates -#} |
| 125 |
{%- if "eseries_proxy_client_certificate_certificates" in (hostvars[array].keys() | list) -%} |
| 126 |
{%- if hostvars[array]["eseries_proxy_client_certificate_certificates"] is string -%} |
| 127 |
{%- if hostvars[array]["eseries_proxy_client_certificate_certificates"] not in certs -%} |
| 128 |
{%- if certs.append(hostvars[array]["eseries_proxy_client_certificate_certificates"]) -%}{%- endif -%} |
| 129 |
{%- endif -%} |
| 130 |
{%- elif hostvars[array]["eseries_proxy_client_certificate_certificates"] is iterable -%} |
| 131 |
{%- for client_cert in hostvars[array]["eseries_proxy_client_certificate_certificates"] if client_cert not in certs -%} |
| 132 |
{%- if certs.append(client_cert) -%}{%- endif -%} |
| 133 |
{%- endfor -%} |
| 134 |
{%- endif -%} |
| 135 |
{%- endif -%} |
| 136 |
|
| 137 |
{%- if systems.update({hostvars[array]["eseries_proxy_api_url"]: { |
| 138 |
"proxy_username": hostvars[array]["eseries_proxy_api_username"] | default('admin'), |
| 139 |
"proxy_password": hostvars[array]["eseries_proxy_api_password"], |
| 140 |
"proxy_validate_certs": hostvars[array]["eseries_validate_certs"] | default(omit), |
| 141 |
"certificates": certs}}) %} |
| 142 |
{%- endif %} |
| 143 |
{%- endif %} |
| 144 |
{%- endfor %} |
| 145 |
{{ systems }} |
| 146 |
|
| 147 |
- name: Ensure proxy server certificates are installed |
| 148 |
na_santricity_server_certificate: |
| 149 |
ssid: proxy |
| 150 |
api_url: "{{ item['key'] }}" |
| 151 |
api_username: "{{ item['value']['proxy_username'] }}" |
| 152 |
api_password: "{{ item['value']['proxy_password'] }}" |
| 153 |
validate_certs: "{{ item['value']['proxy_validate_certs'] }}" |
| 154 |
certificates: "{{ item['value']['certificates'] }}" |
| 155 |
passphrase: "{{ item['value']['passphrase'] }}" |
| 156 |
connection: local |
| 157 |
loop: "{{ lookup('dict', proxy_server_certificates, wantlist=True) }}" |
| 158 |
when: item['value']['certificates'] | length > 0 |
| 159 |
no_log: true |
| 160 |
vars: |
| 161 |
proxy_server_certificates: |- |
| 162 |
{#- Build a dictionary of all inventoried proxies keyed by their api url #} |
| 163 |
{%- set systems = {} %} |
| 164 |
{%- for array in ansible_play_hosts_all %} |
| 165 |
{%- if "eseries_proxy_api_url" in hostvars[array] and "eseries_proxy_api_password" in hostvars[array] %} |
| 166 |
{%- set certs = [] -%} |
| 167 |
|
| 168 |
{#- Add common proxy server certificates -#} |
| 169 |
{%- if "eseries_proxy_server_certificate_common_certificates" in (hostvars[array].keys() | list) -%} |
| 170 |
{%- if hostvars[array]["eseries_proxy_server_certificate_common_certificates"] is string -%} |
| 171 |
{%- if certs.append(hostvars[array]["eseries_proxy_server_certificate_common_certificates"]) -%}{%- endif -%} |
| 172 |
{%- elif hostvars[array]["eseries_proxy_server_certificate_common_certificates"] is iterable -%} |
| 173 |
{%- if certs.extend(hostvars[array]["eseries_proxy_server_certificate_common_certificates"]) -%}{%- endif -%} |
| 174 |
{%- endif -%} |
| 175 |
{%- endif -%} |
| 176 |
|
| 177 |
{#- Add proxy specific server certificates -#} |
| 178 |
{%- if "eseries_proxy_server_certificate_certificates" in (hostvars[array].keys() | list) -%} |
| 179 |
{%- if hostvars[array]["eseries_proxy_server_certificate_certificates"] is string -%} |
| 180 |
{%- if hostvars[array]["eseries_proxy_server_certificate_certificates"] not in certs -%} |
| 181 |
{%- if certs.append(hostvars[array]["eseries_proxy_server_certificate_certificates"]) -%}{%- endif -%} |
| 182 |
{%- endif -%} |
| 183 |
{%- elif hostvars[array]["eseries_proxy_server_certificate_certificates"] is iterable -%} |
| 184 |
{%- for client_cert in hostvars[array]["eseries_proxy_server_certificate_certificates"] if client_cert not in certs -%} |
| 185 |
{%- if certs.append(client_cert) -%}{%- endif -%} |
| 186 |
{%- endfor -%} |
| 187 |
{%- endif -%} |
| 188 |
{%- endif -%} |
| 189 |
|
| 190 |
{%- if systems.update({hostvars[array]["eseries_proxy_api_url"]: { |
| 191 |
"proxy_username": hostvars[array]["eseries_proxy_api_username"] | default('admin'), |
| 192 |
"proxy_password": hostvars[array]["eseries_proxy_api_password"], |
| 193 |
"proxy_validate_certs": hostvars[array]["eseries_validate_certs"] | default(omit), |
| 194 |
"certificates": certs, |
| 195 |
"passphrase": hostvars[array]["eseries_proxy_server_certificate_passphrase"] | default(hostvars[array]["eseries_proxy_server_certificate_common_passphrase"] | default(omit))}}) %} |
| 196 |
{%- endif %} |
| 197 |
{%- endif %} |
| 198 |
{%- endfor %} |
| 199 |
{{ systems }} |
| 200 |
|
| 201 |
- name: Ensure proxy LDAP have been configured |
| 202 |
na_santricity_ldap: |
| 203 |
ssid: proxy |
| 204 |
api_url: "{{ item['key'] }}" |
| 205 |
api_username: "{{ item['value']['proxy_username'] }}" |
| 206 |
api_password: "{{ item['value']['current_password'] | default(item['value']['proxy_password']) }}" |
| 207 |
validate_certs: "{{ item['value']['proxy_validate_certs'] }}" |
| 208 |
state: "{{ item['value']['ldap_state'] }}" |
| 209 |
identifier: "{{ item['value']['ldap_identifier'] | default(omit) }}" |
| 210 |
server_url: "{{ item['value']['ldap_server'] | default(omit) }}" |
| 211 |
bind_user: "{{ item['value']['ldap_bind_username'] | default(omit) }}" |
| 212 |
bind_password: "{{ item['value']['ldap_bind_password'] | default(omit) }}" |
| 213 |
search_base: "{{ item['value']['ldap_search_base'] | default(omit) }}" |
| 214 |
user_attribute: "{{ item['value']['ldap_user_attribute'] | default(omit) }}" |
| 215 |
role_mappings: "{{ item['value']['ldap_role_mappings'] | default(omit) }}" |
| 216 |
ignore_errors: true |
| 217 |
connection: local |
| 218 |
loop: "{{ lookup('dict', proxy_admin, wantlist=True) }}" |
| 219 |
vars: |
| 220 |
proxy_admin: |- |
| 221 |
{#- Build a dictionary of all inventoried proxies keyed by their api url #} |
| 222 |
{%- set systems = {} %} |
| 223 |
{%- for array in ansible_play_hosts_all %} |
| 224 |
{%- if "eseries_proxy_api_url" in hostvars[array] and "eseries_proxy_api_password" in hostvars[array] and "eseries_proxy_ldap_state" in hostvars[array] %} |
| 225 |
{%- if systems.update({hostvars[array]["eseries_proxy_api_url"]: { |
| 226 |
"proxy_username": hostvars[array]["eseries_proxy_api_username"] | default('admin'), |
| 227 |
"proxy_password": hostvars[array]["eseries_proxy_api_password"], |
| 228 |
"current_proxy_password": hostvars[array]["eseries_proxy_current_api_password"] | default(omit), |
| 229 |
"proxy_validate_certs": hostvars[array]["eseries_validate_certs"] | default(omit), |
| 230 |
"ldap_state": hostvars[array]["eseries_proxy_ldap_state"], |
| 231 |
"ldap_identifier": hostvars[array]["eseries_proxy_ldap_identifier"] | default(omit), |
| 232 |
"ldap_server": hostvars[array]["eseries_proxy_ldap_server"] | default(omit), |
| 233 |
"ldap_bind_username": hostvars[array]["eseries_proxy_ldap_bind_username"] | default(omit), |
| 234 |
"ldap_bind_password": hostvars[array]["eseries_proxy_ldap_bind_password"] | default(omit), |
| 235 |
"ldap_search_base": hostvars[array]["eseries_proxy_ldap_search_base"] | default(omit), |
| 236 |
"ldap_user_attribute": hostvars[array]["eseries_proxy_ldap_user_attribute"] | default(omit), |
| 237 |
"ldap_role_mappings": hostvars[array]["eseries_proxy_ldap_role_mappings"] | default(omit)}}) %} |
| 238 |
{%- endif %} |
| 239 |
{%- endif %} |
| 240 |
{%- endfor %} |
| 241 |
{{ systems }} |