Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'ansible-lint' violations for 'disaster_recovery' role (part 1 - 'yamllint' warnings) #543

Merged
merged 4 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions automation/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ cd "$COLLECTION_DIR"
ansible-test sanity
antsibull-changelog lint -v
ansible-lint roles/* --exclude roles/hosted_engine_setup --exclude roles/disaster_recovery --exclude roles/remove_stale_lun -x experimental
ansible-lint -x var-spacing,unnamed-task,fqcn-builtins,no-changed-when,risky-shell-pipe,ignore-errors roles/disaster_recovery

cd "$ROOT_PATH"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- Fix "ansible-lint" version 6.0.0 "yaml" violations for "disaster_recovery" role (https://github.com/oVirt/ovirt-ansible-collection/pull/543).
10 changes: 5 additions & 5 deletions roles/disaster_recovery/examples/disaster_recovery_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ dr_import_storages:
dr_secondary_name: "secondary_master_storage"

- dr_domain_type: "nfs"
dr_wipe_after_delete: False
dr_backup: False
dr_wipe_after_delete: false
dr_backup: false
dr_critical_space_action_blocker: 5
dr_warning_low_space: 5
dr_primary_master_domain: "False"
Expand All @@ -31,14 +31,14 @@ dr_import_storages:
dr_primary_path: "/export/path2"
dr_primary_dc_name: "Prod"
dr_secondary_name: "path2"
dr_secondary_master_domain: False
dr_secondary_master_domain: false
dr_secondary_address: "yy.yy.yy.yy"
dr_secondary_path: "/export/path2"
dr_secondary_dc_name: "Recovery"

- dr_domain_type: "iscsi"
dr_wipe_after_delete: False
dr_backup: False
dr_wipe_after_delete: false
dr_backup: false
dr_critical_space_action_blocker: 1
dr_warning_low_space: 5
dr_primary_master_domain: "False"
Expand Down
2 changes: 1 addition & 1 deletion roles/disaster_recovery/examples/dr_ovirt_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
roles:
- disaster_recovery
collections:
- @NAMESPACE@.@NAME@
- @NAMESPACE@.@NAME@
2 changes: 1 addition & 1 deletion roles/disaster_recovery/examples/dr_play.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
roles:
- disaster_recovery
collections:
- @NAMESPACE@.@NAME@
- @NAMESPACE@.@NAME@
10 changes: 5 additions & 5 deletions roles/disaster_recovery/tasks/clean/remove_disks.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
- block:
- name: Remove disk
ovirt_disk:
state: absent
id: "{{ disk.id }}"
auth: "{{ ovirt_auth }}"
state: absent
id: "{{ disk.id }}"
auth: "{{ ovirt_auth }}"
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
- fail_back
- clean_engine
- fail_back
- clean_engine
18 changes: 9 additions & 9 deletions roles/disaster_recovery/tasks/clean/remove_domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
# We should wait for some time and try again
- name: Remove storage domain
ovirt_storage_domain:
state: absent
id: "{{ sd.id }}"
name: "{{ sd.name }}"
auth: "{{ ovirt_auth }}"
host: "{{ host }}"
destroy: "{{ dr_force }}"
data_center: "{{ sp_uuid }}"
state: absent
id: "{{ sd.id }}"
name: "{{ sd.name }}"
auth: "{{ ovirt_auth }}"
host: "{{ host }}"
destroy: "{{ dr_force }}"
data_center: "{{ sp_uuid }}"
register: result
until: dr_force or result is not failed
retries: "{{ dr_cleanup_retries_maintenance }}"
delay: "{{ dr_cleanup_delay_maintenance }}"
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
- fail_back
- clean_engine
- fail_back
- clean_engine
8 changes: 4 additions & 4 deletions roles/disaster_recovery/tasks/clean/remove_domain_process.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
- name: Remove storage domain with no force
include_tasks: remove_domain.yml
vars:
host: "{{ host_info.ovirt_hosts[0].id }}"
host: "{{ host_info.ovirt_hosts[0].id }}"
when: "host_info.ovirt_hosts is defined and host_info.ovirt_hosts|length > 0 and not dr_force"

- name: Force remove storage domain
include_tasks: remove_domain.yml
vars:
host: "00000000-0000-0000-0000-000000000000"
host: "00000000-0000-0000-0000-000000000000"
when: "dr_force"
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
- fail_back
- clean_engine
- fail_back
- clean_engine
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
- block:
- name: Fetch invalid storage domain for remove
ovirt_storage_domain_info:
pattern: name={{ storage['dr_' + dr_source_map + '_name'] }} and {{ dr_inactive_domain_search }}
auth: "{{ ovirt_auth }}"
pattern: name={{ storage['dr_' + dr_source_map + '_name'] }} and {{ dr_inactive_domain_search }}
auth: "{{ ovirt_auth }}"
register: storage_domain_info

- name: Remove invalid storage domain
include_tasks: remove_domain_process.yml
vars:
sd: "{{ sd }}"
sd: "{{ sd }}"
with_items:
- "{{ storage_domain_info.ovirt_storage_domains }}"
- "{{ storage_domain_info.ovirt_storage_domains }}"
when: (not only_master and not sd.master) or (only_master and sd.master)
loop_control:
loop_var: sd
loop_var: sd
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
- fail_back
- clean_engine
- fail_back
- clean_engine
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
- block:
- name: Fetch active/maintenance/detached storage domain for remove
ovirt_storage_domain_info:
pattern: >
name={{ storage['dr_' + dr_source_map + '_name'] }} and
(
datacenter={{ storage['dr_' + dr_source_map + '_dc_name'] }} and {{ dr_active_domain_search }} or
datacenter={{ storage['dr_' + dr_source_map + '_dc_name'] }} and {{ dr_maintenance_domain_search }} or
{{ dr_unattached_domain_search }}
)
auth: "{{ ovirt_auth }}"
pattern: >
name={{ storage['dr_' + dr_source_map + '_name'] }} and
(
datacenter={{ storage['dr_' + dr_source_map + '_dc_name'] }} and {{ dr_active_domain_search }} or
datacenter={{ storage['dr_' + dr_source_map + '_dc_name'] }} and {{ dr_maintenance_domain_search }} or
{{ dr_unattached_domain_search }}
)
auth: "{{ ovirt_auth }}"
register: storage_domain_info

- name: Remove valid storage domain
include_tasks: remove_domain_process.yml
vars:
sd: "{{ sd }}"
sd: "{{ sd }}"
with_items:
- "{{ storage_domain_info.ovirt_storage_domains }}"
- "{{ storage_domain_info.ovirt_storage_domains }}"
when: (not only_master and not sd.master) or (only_master and sd.master)
loop_control:
loop_var: sd
loop_var: sd
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
- fail_back
- clean_engine
- fail_back
- clean_engine
10 changes: 5 additions & 5 deletions roles/disaster_recovery/tasks/clean/remove_vms.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
- block:
- name: Remove diskless VMs
ovirt_vm:
state: absent
name: "{{ vm.name }}"
auth: "{{ ovirt_auth }}"
state: absent
name: "{{ vm.name }}"
auth: "{{ ovirt_auth }}"
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
- fail_back
- clean_engine
- fail_back
- clean_engine
14 changes: 7 additions & 7 deletions roles/disaster_recovery/tasks/clean/shutdown_vm.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
- block:
- name: Shutdown VM
ovirt_vm:
state: stopped
name: "{{ vms.name }}"
force: True
wait: True
auth: "{{ ovirt_auth }}"
state: stopped
name: "{{ vms.name }}"
force: true
wait: true
auth: "{{ ovirt_auth }}"
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
- fail_back
- clean_engine
- fail_back
- clean_engine
16 changes: 8 additions & 8 deletions roles/disaster_recovery/tasks/clean/shutdown_vms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
# Get all the running VMs related to a storage domain and shut them down
- name: Fetch VMs in the storage domain
ovirt_vm_info:
pattern: >
status != down and
storage.name={{ storage['dr_' + dr_source_map + '_name'] }} and
datacenter={{ storage['dr_' + dr_source_map + '_dc_name'] }}
auth: "{{ ovirt_auth }}"
pattern: >
status != down and
storage.name={{ storage['dr_' + dr_source_map + '_name'] }} and
datacenter={{ storage['dr_' + dr_source_map + '_dc_name'] }}
auth: "{{ ovirt_auth }}"
register: vm_info

# TODO: Add a wait until the VM is really down
- name: Shutdown VMs
include_tasks: shutdown_vm.yml
vars:
vms: "{{ item }}"
vms: "{{ item }}"
with_items: "{{ vm_info.ovirt_vms }}"
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
- fail_back
- clean_engine
- fail_back
- clean_engine
14 changes: 7 additions & 7 deletions roles/disaster_recovery/tasks/clean/update_ovf_store.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
- block:
- name: Fetch storage domain only if active
ovirt_storage_domain_info:
pattern: status = active and storage.name={{ storage['dr_' + dr_source_map + '_name'] }}
auth: "{{ ovirt_auth }}"
pattern: status = active and storage.name={{ storage['dr_' + dr_source_map + '_name'] }}
auth: "{{ ovirt_auth }}"
register: storage_domain_info

- name: Update OVF store for active storage domain
ovirt_storage_domain:
state: update_ovf_store
name: "{{ iscsi_storage['dr_' + dr_source_map + '_name'] }}"
auth: "{{ ovirt_auth }}"
state: update_ovf_store
name: "{{ iscsi_storage['dr_' + dr_source_map + '_name'] }}"
auth: "{{ ovirt_auth }}"
with_items:
- "{{ storage_domain_info.ovirt_storage_domains }}"
ignore_errors: "{{ dr_ignore_error_clean }}"
tags:
- fail_back
- clean_engine
- fail_back
- clean_engine
Loading