| 1 |
- name: Determine if any snapshot consistency group views are not specified. |
| 2 |
block: |
| 3 |
- name: Retrieve all snapshot consistency groups |
| 4 |
uri: |
| 5 |
url: "{{ current_eseries_api_url }}storage-systems/{{ current_eseries_ssid }}/consistency-groups" |
| 6 |
method: GET |
| 7 |
url_password: "{{ current_eseries_api_password }}" |
| 8 |
url_username: "{{ current_eseries_api_username }}" |
| 9 |
validate_certs: "{{ current_eseries_validate_certs | default(omit) }}" |
| 10 |
connection: local |
| 11 |
register: existing_consistency_groups |
| 12 |
|
| 13 |
- name: Retrieve all snapshot consistency group views |
| 14 |
uri: |
| 15 |
url: "{{ current_eseries_api_url }}storage-systems/{{ current_eseries_ssid }}/consistency-groups/views" |
| 16 |
method: GET |
| 17 |
url_password: "{{ current_eseries_api_password }}" |
| 18 |
url_username: "{{ current_eseries_api_username }}" |
| 19 |
validate_certs: "{{ current_eseries_validate_certs | default(omit) }}" |
| 20 |
connection: local |
| 21 |
register: existing_consistency_group_views |
| 22 |
|
| 23 |
- name: Ensure all unspecified snapshot consistency group views are removed. |
| 24 |
na_santricity_snapshot: |
| 25 |
ssid: "{{ current_eseries_ssid }}" |
| 26 |
api_url: "{{ current_eseries_api_url }}" |
| 27 |
api_username: "{{ current_eseries_api_username }}" |
| 28 |
api_password: "{{ current_eseries_api_password }}" |
| 29 |
validate_certs: "{{ current_eseries_validate_certs | default(omit) }}" |
| 30 |
state: absent |
| 31 |
type: view |
| 32 |
group_name: "{{ item['group_name'] }}" |
| 33 |
view_name: "{{ item['view_name'] }}" |
| 34 |
connection: local |
| 35 |
loop: "{{ unspecified_groups }}" |
| 36 |
vars: |
| 37 |
unspecified_groups: |- |
| 38 |
{%- set unspecified_group_views = [] -%} |
| 39 |
{%- for existing_view in existing_consistency_group_views["json"] -%} |
| 40 |
{%- for view in eseries_snapshot_views | default([]) if existing_view["name"] == view["name"] -%} |
| 41 |
{#- DO NOTHING -#} |
| 42 |
{%- else -%} |
| 43 |
{%- for group in existing_consistency_groups["json"] if group["id"] == existing_view["groupRef"] -%} |
| 44 |
{%- if unspecified_group_views.append({"group_name": group["name"], "view_name": existing_view["name"]}) -%}{%- endif -%} |
| 45 |
{%- endfor -%} |
| 46 |
{%- endfor -%} |
| 47 |
{%- endfor -%} |
| 48 |
{{- unspecified_group_views -}} |
| 49 |
when: (eseries_remove_all_configuration | default(False)) == False and eseries_snapshot_remove_unspecified == True |
| 50 |
|
| 51 |
- name: "Ensure all snapshot consistency views {{'exist' if (eseries_remove_all_configuration_state | default('present')) == 'present' else 'are removed' }}." |
| 52 |
na_santricity_snapshot: |
| 53 |
ssid: "{{ current_eseries_ssid }}" |
| 54 |
api_url: "{{ current_eseries_api_url }}" |
| 55 |
api_username: "{{ current_eseries_api_username }}" |
| 56 |
api_password: "{{ current_eseries_api_password }}" |
| 57 |
validate_certs: "{{ current_eseries_validate_certs | default(omit) }}" |
| 58 |
state: "{{ eseries_remove_all_configuration_state | default('present') }}" |
| 59 |
type: view |
| 60 |
view_name: "{{ item['name'] }}" |
| 61 |
group_name: "{{ item['group_name'] }}" |
| 62 |
pit_name: "{{ item['pit_name'] | default(omit) }}" |
| 63 |
pit_timestamp: "{{ item['pit_timestamp'] | default(omit) }}" |
| 64 |
volumes: "{{ item['volumes'] | default(omit) }}" |
| 65 |
reserve_capacity_pct: "{{ item['reserve_capacity_pct'] | default(omit) }}" |
| 66 |
preferred_reserve_storage_pool: "{{ item['preferred_reserve_storage_pool'] | default(omit) }}" |
| 67 |
alert_threshold_pct: "{{ item['alert_threshold_pct'] | default(omit) }}" |
| 68 |
view_host: "{{ item['host'] | default(omit) }}" |
| 69 |
view_writable: "{{ item['writable'] | default(omit) }}" |
| 70 |
view_validate: "{{ item['validate'] | default(omit) }}" |
| 71 |
connection: local |
| 72 |
loop: "{{ consistency_group_views }}" |
| 73 |
vars: |
| 74 |
consistency_group_views: |- |
| 75 |
{%- set consistency_group_views = [] -%} |
| 76 |
{%- for view in eseries_snapshot_views | default([]) -%} |
| 77 |
{%- set view_info = {"name": view["name"], "group_name": view["group_name"]} -%} |
| 78 |
{%- if "pit_name" in (view.keys() | list) and view_info.update({"pit_name": view["pit_name"]}) -%}{%- endif -%} |
| 79 |
{%- if "pit_timestamp" in (view.keys() | list) and view_info.update({"pit_timestamp": view["pit_timestamp"]}) -%}{%- endif -%} |
| 80 |
|
| 81 |
{%- if "host" in (view.keys() | list) or eseries_snapshot_views_host is defined -%} |
| 82 |
{%- if view_info.update({"host": view["host"] | default(eseries_snapshot_views_host)}) -%}{%- endif -%}{%- endif -%} |
| 83 |
{%- if "reserve_capacity_pct" in (view.keys() | list) or eseries_snapshot_views_reserve_capacity_pct is defined -%} |
| 84 |
{%- if view_info.update({"reserve_capacity_pct": view["reserve_capacity_pct"] | default(eseries_snapshot_views_reserve_capacity_pct)}) -%}{%- endif -%}{%- endif -%} |
| 85 |
{%- if "preferred_reserve_storage_pool" in (view.keys() | list) or eseries_snapshot_views_preferred_reserve_storage_pool is defined -%} |
| 86 |
{%- if view_info.update({"preferred_reserve_storage_pool": view["preferred_reserve_storage_pool"] | default(eseries_snapshot_views_preferred_reserve_storage_pool)}) -%}{%- endif -%}{%- endif -%} |
| 87 |
{%- if "alert_threshold_pct" in (view.keys() | list) or eseries_snapshot_views_alert_threshold_pct is defined -%} |
| 88 |
{%- if view_info.update({"alert_threshold_pct": view["alert_threshold_pct"] | default(eseries_snapshot_views_alert_threshold_pct)}) -%}{%- endif -%}{%- endif -%} |
| 89 |
{%- if "writable" in (view.keys() | list) or eseries_snapshot_views_writable is defined -%} |
| 90 |
{%- if view_info.update({"writable": view["writable"] | default(eseries_snapshot_views_writable)}) -%}{%- endif -%}{%- endif -%} |
| 91 |
{%- if "validate" in (view.keys() | list) or eseries_snapshot_views_validate is defined -%} |
| 92 |
{%- if view_info.update({"validate": view["validate"] | default(eseries_snapshot_views_validate)}) -%}{%- endif -%}{%- endif -%} |
| 93 |
{%- if "alert_threshold_pct" in (view.keys() | list) or eseries_snapshot_views_alert_threshold_pct is defined -%} |
| 94 |
{%- if view_info.update({"alert_threshold_pct": view["alert_threshold_pct"] | default(eseries_snapshot_views_alert_threshold_pct)}) -%}{%- endif -%}{%- endif -%} |
| 95 |
|
| 96 |
{%- if "volumes" in (view.keys() | list) -%} |
| 97 |
{%- if view_info.update({"volumes": [] }) -%}{%- endif -%} |
| 98 |
{%- for volume in view["volumes"] -%} |
| 99 |
{%- set volume_info = {"volume": volume["volume"], |
| 100 |
"reserve_capacity_pct": volume["reserve_capacity_pct"] | default(view_info["reserve_capacity_pct"] | default(False)), |
| 101 |
"snapshot_volume_writable": volume["writable"] | default(view_info["writable"] | default(True)), |
| 102 |
"snapshot_volume_validate": volume["validate"] | default(view_info["validate"] | default(False))} -%} |
| 103 |
|
| 104 |
{%- if "host" in (volume.keys() | list) or "host" in (view_info.keys() | list) -%} |
| 105 |
{%- if volume_info.update({"snapshot_volume_host": volume["host"] | default(view_info["host"])}) -%}{%- endif -%}{%- endif -%} |
| 106 |
{%- if "lun" in (volume.keys() | list) -%} |
| 107 |
{%- if volume_info.update({"snapshot_volume_lun": volume["lun"]}) -%}{%- endif -%}{%- endif -%} |
| 108 |
{%- if "preferred_reserve_storage_pool" in (volume.keys() | list) or "preferred_reserve_storage_pool" in (view_info.keys() | list) -%} |
| 109 |
{%- if volume_info.update({"preferred_reserve_storage_pool": volume["preferred_reserve_storage_pool"] | default(view_info["preferred_reserve_storage_pool"])}) -%}{%- endif -%}{%- endif -%} |
| 110 |
|
| 111 |
{%- if view_info["volumes"].append(volume_info) -%}{%- endif -%} |
| 112 |
{%- endfor -%} |
| 113 |
{%- endif -%} |
| 114 |
{%- if consistency_group_views.append(view_info) -%}{%- endif -%} |
| 115 |
{%- endfor -%} |
| 116 |
{{- consistency_group_views -}} |