Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #61 from oVirt/BZ1640155
Browse files Browse the repository at this point in the history
Use vars instead of inline variables for include_tasks
  • Loading branch information
maorlipchuk authored Oct 22, 2018
2 parents b35f369 + d2f038a commit b98ef7a
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 25 deletions.
8 changes: 6 additions & 2 deletions tasks/clean/remove_domain_process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@
when: sp_uuid

- name: Remove storage domain with no force
include_tasks: tasks/clean/remove_domain.yml host={{ ovirt_hosts[0].id }}
include_tasks: tasks/clean/remove_domain.yml
vars:
host: "{{ ovirt_hosts[0].id }}"
when: "ovirt_hosts is defined and ovirt_hosts|length > 0 and not dr_force"

- name: Force remove storage domain
include_tasks: tasks/clean/remove_domain.yml host="00000000-0000-0000-0000-000000000000"
include_tasks: tasks/clean/remove_domain.yml
vars:
host: "00000000-0000-0000-0000-000000000000"
when: "dr_force"
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
Expand Down
4 changes: 3 additions & 1 deletion tasks/clean/remove_invalid_filtered_master_domains.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
auth: "{{ ovirt_auth }}"

- name: Remove invalid storage domain
include_tasks: tasks/clean/remove_domain_process.yml sd={{ sd }}
include_tasks: tasks/clean/remove_domain_process.yml
vars:
sd: "{{ sd }}"
with_items:
- "{{ ovirt_storage_domains }}"
when: (not only_master and not sd.master) or (only_master and sd.master)
Expand Down
4 changes: 3 additions & 1 deletion tasks/clean/remove_valid_filtered_master_domains.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
auth: "{{ ovirt_auth }}"

- name: Remove valid storage domain
include_tasks: tasks/clean/remove_domain_process.yml sd={{ sd }}
include_tasks: tasks/clean/remove_domain_process.yml
vars:
sd: "{{ sd }}"
with_items:
- "{{ ovirt_storage_domains }}"
when: (not only_master and not sd.master) or (only_master and sd.master)
Expand Down
4 changes: 3 additions & 1 deletion tasks/clean/shutdown_vms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

# TODO: Add a wait until the VM is really down
- name: Shutdown VMs
include_tasks: tasks/clean/shutdown_vm.yml vms={{ item }}
include_tasks: tasks/clean/shutdown_vm.yml
vars:
vms: "{{ item }}"
with_items: "{{ ovirt_vms }}"
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
Expand Down
34 changes: 25 additions & 9 deletions tasks/clean_engine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
ca_file: "{{ vars['dr_sites_' + dr_source_map + '_ca_file'] }}"

- name: Shutdown running VMs
include_tasks: tasks/clean/shutdown_vms.yml storage={{ item }}
include_tasks: tasks/clean/shutdown_vms.yml
vars:
storage: "{{ item }}"
with_items:
- "{{ dr_import_storages }}"
loop_control:
loop_var: storage

- name: Update OVF_STORE disk for storage domains
include_tasks: tasks/clean/update_ovf_store.yml storage={{ item }}
include_tasks: tasks/clean/update_ovf_store.yml
vars:
storage: "{{ item }}"
with_items:
- "{{ dr_import_storages }}"
loop_control:
Expand All @@ -36,7 +40,9 @@
set_fact: only_master=False

- name: Remove non master storage domains with valid statuses
include_tasks: tasks/clean/remove_valid_filtered_master_domains.yml storage={{ item }}
include_tasks: tasks/clean/remove_valid_filtered_master_domains.yml
vars:
storage: "{{ item }}"
with_items:
- "{{ dr_import_storages }}"
loop_control:
Expand All @@ -48,7 +54,9 @@
set_fact: dr_force=True

- name: Remove non master storage domains with invalid statuses using force remove
include_tasks: tasks/clean/remove_invalid_filtered_master_domains.yml storage={{ item }}
include_tasks: tasks/clean/remove_invalid_filtered_master_domains.yml
vars:
storage: "{{ item }}"
with_items:
- "{{ dr_import_storages }}"
loop_control:
Expand All @@ -61,7 +69,9 @@
set_fact: dr_force=False

- name: Remove master storage domains with valid statuses
include_tasks: tasks/clean/remove_valid_filtered_master_domains.yml storage={{ item }}
include_tasks: tasks/clean/remove_valid_filtered_master_domains.yml
vars:
storage: "{{ item }}"
with_items:
- "{{ dr_import_storages }}"
loop_control:
Expand All @@ -71,7 +81,9 @@
set_fact: dr_force=True

- name: Remove master storage domains with invalid statuses using force remove
include_tasks: tasks/clean/remove_invalid_filtered_master_domains.yml storage={{ item }}
include_tasks: tasks/clean/remove_invalid_filtered_master_domains.yml
vars:
storage: "{{ item }}"
with_items:
- "{{ dr_import_storages }}"
loop_control:
Expand All @@ -91,7 +103,9 @@
when: dr_clean_orphaned_vms and ovirt_storage_domains | length == 0

- name: Remove vms if no storage domains left in setup
include_tasks: tasks/clean/remove_vms.yml vm={{ item }}
include_tasks: tasks/clean/remove_vms.yml
vars:
vm: "{{ item }}"
with_items: "{{ ovirt_vms }}"
when: dr_clean_orphaned_vms and ovirt_storage_domains | length == 0

Expand All @@ -103,7 +117,9 @@
when: dr_clean_orphaned_disks and ovirt_storage_domains | length == 0

- name: Remove LUN disks if no storage domains left in setup
include_tasks: tasks/clean/remove_disks.yml disk={{ item }}
include_tasks: tasks/clean/remove_disks.yml
vars:
disk: "{{ item }}"
with_items: "{{ ovirt_disks }}"
when: dr_clean_orphaned_disks and ovirt_storage_domains | length == 0

Expand All @@ -114,7 +130,7 @@
- fail_back
- clean_engine

- always:
always:
- name: Revoke the SSO token
ovirt_auth:
state: absent
Expand Down
26 changes: 19 additions & 7 deletions tasks/recover_engine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@
# do we still want to continue and attach the other storage
# domain (which will make another storage domain as master instead).
- name: Add master storage domain to the setup
include_tasks: tasks/recover/add_domain.yml storage={{ item }}
include_tasks: tasks/recover/add_domain.yml
vars:
storage: "{{ item }}"
with_items:
- "{{ dr_import_storages }}"
when: item['dr_' + dr_target_host + '_master_domain']

- name: Add non master storage domains to the setup
include_tasks: tasks/recover/add_domain.yml storage={{ item }}
include_tasks: tasks/recover/add_domain.yml
vars:
storage: "{{ item }}"
with_items:
- "{{ dr_import_storages }}"
when: not item['dr_' + dr_target_host + '_master_domain']
Expand Down Expand Up @@ -160,26 +164,34 @@
# We register the Templates first since we might have
# VMs which are based on them
- name: Register templates
include_tasks: tasks/recover/register_templates.yml storage={{ item }}
include_tasks: tasks/recover/register_templates.yml
vars:
storage: "{{ item }}"
with_items:
- "{{ ovirt_storage_domains }}"

# Register all the unregistered VMs after we registerd
# all the templates from the active storage domains fetched before.
- name: Register VMs
include_tasks: tasks/recover/register_vms.yml storage={{ item }}
include_tasks: tasks/recover/register_vms.yml
vars:
storage: "{{ item }}"
with_items:
- "{{ ovirt_storage_domains }}"

# Run all the high availability VMs.
- name: Run highly available VMs
include_tasks: tasks/recover/run_vms.yml vms={{ item }}
include_tasks: tasks/recover/run_vms.yml
vars:
vms: "{{ item }}"
with_items: "{{ unreg_vms }}"
when: item.status == 'up' and item.high_availability.enabled | bool

# Run all the rest of the VMs.
- name: Run the rest of the VMs
include_tasks: tasks/recover/run_vms.yml vms={{ item }}
include_tasks: tasks/recover/run_vms.yml
vars:
vms: "{{ item }}"
with_items: "{{ unreg_vms }}"
when: item.status == 'up' and not item.high_availability.enabled | bool

Expand All @@ -189,7 +201,7 @@
- fail_over
- fail_back

- always:
always:
- name: Print operation summary
include_tasks: tasks/recover/print_info.yml
- name: Revoke the SSO token
Expand Down
10 changes: 7 additions & 3 deletions tasks/run_unregistered_entities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
state: absent

- name: Run all the high availability VMs
include_tasks: tasks/recover/run_vms.yml vms={{ item }}
include_tasks: tasks/recover/run_vms.yml
vars:
vms: "{{ item }}"
with_items: "{{ running_vms_fail_back }}"
when: item.high_availability.enabled | bool

- name: Run all the entire running VMs
include_tasks: tasks/recover/run_vms.yml vms={{ item }}
include_tasks: tasks/recover/run_vms.yml
vars:
vms: "{{ item }}"
with_items: "{{ running_vms_fail_back }}"
when: not item.high_availability.enabled | bool

Expand All @@ -29,7 +33,7 @@
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
- fail_back
- always:
always:
- name: Revoke the SSO token
ovirt_auth:
state: absent
Expand Down
2 changes: 1 addition & 1 deletion tasks/unregister_entities.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
- fail_back
- always:
always:
- name: Revoke the SSO token
ovirt_auth:
state: absent
Expand Down

0 comments on commit b98ef7a

Please sign in to comment.