1- block: 2 - name: Obtain SSO token 3 ovirt_auth: 4 url: "{{ vars['dr_sites_' + dr_source_map + '_url'] }}" 5 username: "{{ vars['dr_sites_' + dr_source_map + '_username'] }}" 6 password: "{{ vars['dr_sites_' + dr_source_map + '_password'] }}" 7 ca_file: "{{ vars['dr_sites_' + dr_source_map + '_ca_file'] }}" 8 9 - name: Shutdown running VMs 10 include_tasks: clean/shutdown_vms.yml 11 with_items: 12 - "{{ dr_import_storages }}" 13 loop_control: 14 loop_var: storage 15 16 - name: Update OVF_STORE disk for storage domains 17 include_tasks: clean/update_ovf_store.yml 18 with_items: 19 - "{{ dr_import_storages }}" 20 loop_control: 21 loop_var: storage 22 23 - name: Set force remove flag to false for non master domains 24 set_fact: dr_force=False 25 26 # Set all the queries suffix to fetch a storage domain in a specific status. 27 # Note: Export storage domain is not supported and should not be part of storage mapping 28 - name: Setup queries for storage domains 29 set_fact: 30 dr_active_domain_search='status = active and type != cinder' 31 dr_maintenance_domain_search='status = maintenance and type != cinder' 32 dr_unattached_domain_search='status = unattached and type != cinder and type != glance' 33 dr_inactive_domain_search='type != glance and type != cinder and status != active' 34 35 - name: Set master storage domain filter 36 set_fact: only_master=False 37 38 - name: Remove non master storage domains with valid statuses 39 include_tasks: clean/remove_valid_filtered_master_domains.yml 40 with_items: 41 - "{{ dr_import_storages }}" 42 loop_control: 43 loop_var: storage 44 45 # We use inactive filter only at the end, since we are not sure if there were any storage domains 46 # which became inactive on the process or if there were any at the beginning. 47 - name: Set force remove flag to true for non master domains 48 set_fact: dr_force=True 49 50 - name: Remove non master storage domains with invalid statuses using force remove 51 include_tasks: clean/remove_invalid_filtered_master_domains.yml 52 with_items: 53 - "{{ dr_import_storages }}" 54 loop_control: 55 loop_var: storage 56 57 - name: Set master storage domain filter 58 set_fact: only_master=True 59 60 - name: Set force remove flag to false for master domain 61 set_fact: dr_force=False 62 63 - name: Remove master storage domains with valid statuses 64 include_tasks: clean/remove_valid_filtered_master_domains.yml 65 with_items: 66 - "{{ dr_import_storages }}" 67 loop_control: 68 loop_var: storage 69 70 - name: Set force remove flag to true for master domain 71 set_fact: dr_force=True 72 73 - name: Remove master storage domains with invalid statuses using force remove 74 include_tasks: clean/remove_invalid_filtered_master_domains.yml 75 with_items: 76 - "{{ dr_import_storages }}" 77 loop_control: 78 loop_var: storage 79 80 - name: Fetch leftover storage domains 81 ovirt_storage_domain_info: 82 pattern: type != glance 83 auth: "{{ ovirt_auth }}" 84 register: storage_domain_info 85 86 # TODO: Document that behavior 87 # Remove VMs only if there are no data storage domains left in the setup 88 - name: Fetch leftover VMs in the setup 89 ovirt_vm_info: 90 pattern: status = down 91 auth: "{{ ovirt_auth }}" 92 register: vm_info 93 when: dr_clean_orphaned_vms and storage_domain_info.ovirt_storage_domains | length == 0 94 95 - name: Remove vms if no storage domains left in setup 96 include_tasks: clean/remove_vms.yml 97 vars: 98 vm: "{{ item }}" 99 with_items: "{{ vm_info.ovirt_vms }}" 100 when: dr_clean_orphaned_vms and storage_domain_info.ovirt_storage_domains | length == 0 101 102 # Remove direct LUN disks 103 - name: Fetch leftover direct LUN disks in the setup 104 ovirt_disk_info: 105 pattern: disk_type = lun and number_of_vms =0 106 auth: "{{ ovirt_auth }}" 107 register: disk_info 108 when: dr_clean_orphaned_disks and storage_domain_info.ovirt_storage_domains | length == 0 109 110 - name: Remove LUN disks if no storage domains left in setup 111 include_tasks: clean/remove_disks.yml 112 vars: 113 disk: "{{ item }}" 114 with_items: "{{ disk_info.ovirt_disks }}" 115 when: dr_clean_orphaned_disks and storage_domain_info.ovirt_storage_domains | length == 0 116 117 118 # Default value is set in role defaults 119 ignore_errors: "{{ dr_ignore_error_clean }}" 120 tags: 121 - fail_back 122 - clean_engine 123 124 always: 125 - name: Revoke the SSO token 126 ovirt_auth: 127 state: absent 128 ovirt_auth: "{{ ovirt_auth }}" 129