Skip to content

Commit

Permalink
roles: hosted_engine_setup: align with ansible-lint 5.0.0
Browse files Browse the repository at this point in the history
Fixes oVirt#266

Signed-off-by: Asaf Rachmani <arachman@localhost.localdomain>
  • Loading branch information
Asaf Rachmani committed May 4, 2021
1 parent 94a6e1c commit 8f362f1
Show file tree
Hide file tree
Showing 32 changed files with 6 additions and 144 deletions.
1 change: 1 addition & 0 deletions .cache/collections/ansible_collections/@NAMESPACE@/@NAME@
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
block:
- name: Fetch the value of HOST_KEY_CHECKING
set_fact: host_key_checking="{{ lookup('config', 'HOST_KEY_CHECKING') }}"
- debug: var=host_key_checking
- name: Get the username running the deploy
become: false
command: whoami
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
command: get_xml
name: default
register: default_net_xml
- debug: var=default_net_xml.stdout

- name: IPv6 configuration
block:
- name: Remove IPv4 configuration
Expand Down Expand Up @@ -34,23 +32,20 @@
attribute: prefix
value: "64"
register: editednet2
- debug: var=editednet2
- name: Edit libvirt default network configuration, enable DHCPv6
xml:
xmlstring: "{{ editednet2.xmlstring }}"
xpath: /network/ip[@family='ipv6']/dhcp/range
attribute: start
value: "{{ he_ipv6_subnet_prefix + '::10' }}"
register: editednet3
- debug: var=editednet3
- name: Edit libvirt default network configuration, set DHCPv6 range
xml:
xmlstring: "{{ editednet3.xmlstring }}"
xpath: /network/ip[@family='ipv6']/dhcp/range
attribute: end
value: "{{ he_ipv6_subnet_prefix + '::ff' }}"
register: finaledit6
- debug: var=finaledit
when: ipv6_deployment|bool

- name: IPv4 configuration
Expand Down
7 changes: 2 additions & 5 deletions roles/hosted_engine_setup/tasks/apply_openscap_profile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
- name: Set OpenSCAP datastream path
set_fact:
oscap_datastream: "{{ oscap_dir }}/ssg-{{ oscap_dist | replace('RedHat', 'rhel') | lower }}{{ oscap_ver }}-ds.xml"
- debug: var=oscap_datastream
- name: Verify OpenSCAP datastream
stat:
path: "{{ oscap_datastream }}"
Expand All @@ -23,7 +22,6 @@
register: oscap_profile
changed_when: true
when: oscap_ds_stat.stat.exists
- debug: var=oscap_profile
- name: Apply OpenSCAP profile
command: >-
oscap xccdf eval --profile {{ oscap_profile.stdout }} --remediate
Expand All @@ -44,12 +42,11 @@
command: sysctl -n crypto.fips_enabled
changed_when: true
register: he_fips_enabled
- debug: var=he_fips_enabled
- name: Enforce FIPS mode on CentOS
fail:
msg: "FIPS mode is unsupported on CentOS"
when: oscap_dist == "CentOS" and he_fips_enabled.stdout != "1"
when: oscap_dist == "CentOS" and he_fips_enabled.stdout != "1"
- name: Enforce FIPS mode on Rhel
fail:
msg: "FIPS mode is not enabled as required"
when: oscap_dist == "RedHat" and he_fips_enabled.stdout != "1"
when: oscap_dist == "RedHat" and he_fips_enabled.stdout != "1"
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
name: default
state: active
register: virt_net_out
- debug: var=virt_net_out
- name: Get libvirt interfaces
virt_net:
command: facts
Expand All @@ -32,14 +31,12 @@
environment: "{{ he_cmd_lang }}"
register: route_rules_ipv4
changed_when: true
- debug: var=route_rules_ipv4
- name: Get routing rules, IPv6
command: ip -6 rule
environment: "{{ he_cmd_lang }}"
register: route_rules_ipv6
changed_when: true
when: ipv6_deployment|bool
- debug: var=route_rules_ipv6
- name: Save bridge name
set_fact:
virbr_default: "{{ ansible_libvirt_networks['default']['bridge'] }}"
Expand All @@ -60,15 +57,13 @@
{{ (hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv4']['address']+'/'
+hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv4']['netmask']) |ipv4('host/prefix') }}
when: not ipv6_deployment|bool
- debug: var=virbr_cidr_ipv4
- name: Fetch IPv6 CIDR for {{ virbr_default }}
set_fact:
virbr_cidr_ipv6: >-
{{ (hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv6'][0]['address']+'/'+
hostvars[inventory_hostname]['ansible_'+virbr_default]['ipv6'][0]['prefix']) |
ipv6('host/prefix') if 'ipv6' in hostvars[inventory_hostname]['ansible_'+virbr_default] else None }}
when: ipv6_deployment|bool
- debug: var=virbr_cidr_ipv6
- name: Add IPv4 outbound route rules
command: ip rule add from {{ virbr_cidr_ipv4 }} priority 101 table main
environment: "{{ he_cmd_lang }}"
Expand All @@ -80,7 +75,6 @@
selectattr('src', 'equalto', virbr_cidr_ipv4 | ipaddr('address') ) |
list | length == 0
changed_when: true
- debug: var=result
- name: Add IPv4 inbound route rules
command: ip rule add from all to {{ virbr_cidr_ipv4 }} priority 100 table main
environment: "{{ he_cmd_lang }}"
Expand All @@ -92,19 +86,16 @@
selectattr('priority', 'equalto', 100) |
selectattr('dst', 'equalto', virbr_cidr_ipv4 | ipaddr('address') ) |
list | length == 0
- debug: var=result
- name: Add IPv6 outbound route rules
command: ip -6 rule add from {{ virbr_cidr_ipv6 }} priority 101 table main
environment: "{{ he_cmd_lang }}"
register: result
when: ipv6_deployment|bool and "\"101:\tfrom \"+virbr_cidr_ipv6+\" lookup main\" not in route_rules_ipv6.stdout"
changed_when: true
- debug: var=result
- name: Add IPv6 inbound route rules
command: ip -6 rule add from all to {{ virbr_cidr_ipv6 }} priority 100 table main
environment: "{{ he_cmd_lang }}"
register: result
changed_when: true
when: >-
ipv6_deployment|bool and "\"100:\tfrom all to \"+virbr_cidr_ipv6+\" lookup main\" not in route_rules_ipv6.stdout"
- debug: var=result
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
include_tasks: "{{ item }}"
with_fileglob: "hooks/enginevm_before_engine_setup/*.yml"
register: include_before_engine_setup_results
- debug: var=include_before_engine_setup_results
- name: Restore a backup
block:
- include_tasks: restore_backup.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
include_tasks: "{{ item }}"
with_fileglob: "hooks/enginevm_after_engine_setup/*.yml"
register: include_after_engine_setup_results
- debug: var=include_after_engine_setup_results
# After a restart the engine has a 5 minute grace time,
# other actions like electing a new SPM host or reconstructing
# the master storage domain could require more time
Expand All @@ -18,7 +17,6 @@
register: libgfapi_support_out
changed_when: true
when: he_enable_libgfapi|bool
- debug: var=libgfapi_support_out
- name: Save original OvfUpdateIntervalInMinutes
shell: "engine-config -g OvfUpdateIntervalInMinutes | cut -d' ' -f2 > /root/OvfUpdateIntervalInMinutes.txt"
environment: "{{ he_cmd_lang }}"
Expand All @@ -43,7 +41,6 @@
state: restarted
name: ovirt-engine
register: restart_out
- debug: var=restart_out
- name: Mask cloud-init services to speed up future boot
systemd:
masked: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
until: "'DB Up!Welcome to Health Status!' in engine_status.content"
retries: 30
delay: 20
- debug: var=engine_status
- name: Open a port on firewalld
firewalld:
port: "{{ he_webui_forward_port }}/tcp"
Expand All @@ -27,18 +26,17 @@
async: 86400
poll: 0
register: sshpf
- debug: var=sshpf
- name: Evaluate temporary bootstrap engine URL
set_fact: bootstrap_engine_url="https://{{ he_host_address }}:{{ he_webui_forward_port }}/ovirt-engine/"
- debug:
- name: Display the temporary bootstrap engine URL
debug:
msg: >-
The bootstrap engine is temporary accessible over {{ bootstrap_engine_url }}
- name: Detect VLAN ID
shell: ip -d link show {{ he_bridge_if }} | grep 'vlan ' | grep -Po 'id \K[\d]+' | cat
environment: "{{ he_cmd_lang }}"
register: vlan_id_out
changed_when: true
- debug: var=vlan_id_out
- name: Set Engine public key as authorized key without validating the TLS/SSL certificates
authorized_key:
user: root
Expand Down Expand Up @@ -128,7 +126,6 @@
include_tasks: "{{ item }}"
with_fileglob: "hooks/after_add_host/*.yml"
register: include_after_add_host_results
- debug: var=include_after_add_host_results
- name: Pause the execution to let the user interactively reconfigure the host
block:
- name: Let the user connect to the bootstrap engine to manually fix host configuration
Expand Down Expand Up @@ -156,7 +153,6 @@
retries: 120
delay: 10
ignore_errors: true
- debug: var=host_result_up_check
- name: Notify the user about a failure
fail:
msg: >-
Expand Down
1 change: 0 additions & 1 deletion roles/hosted_engine_setup/tasks/clean_localvm_dir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
path: "{{ he_local_vm_dir }}"
state: absent
register: rm_localvm_dir
- debug: var=rm_localvm_dir
- name: Remove temporary entry in /etc/hosts for the local VM
lineinfile:
dest: /etc/hosts
Expand Down
8 changes: 0 additions & 8 deletions roles/hosted_engine_setup/tasks/create_storage_domain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,16 @@
'up' in host_result.ovirt_hosts[0].status
retries: 50
delay: 10
- debug: var=host_result
- name: Fetch cluster ID
set_fact: cluster_id="{{ host_result.ovirt_hosts[0].cluster.id }}"
- name: Fetch cluster facts
ovirt_cluster_info:
auth: "{{ ovirt_auth }}"
register: cluster_facts
- debug: var=cluster_facts
- name: Fetch Datacenter facts
ovirt_datacenter_info:
auth: "{{ ovirt_auth }}"
register: datacenter_facts
- debug: var=datacenter_facts
- name: Fetch Datacenter ID
set_fact: >-
datacenter_id={{ cluster_facts.ovirt_clusters|json_query("[?id=='" + cluster_id + "'].data_center.id")|first }}
Expand Down Expand Up @@ -119,15 +116,13 @@
pattern: name={{ he_storage_domain_name }}
auth: "{{ ovirt_auth }}"
register: storage_domain_details
- debug: var=storage_domain_details
- name: Find the appliance OVF
find:
paths: "{{ he_local_vm_dir }}/master"
recurse: true
patterns: ^.*.(?<!meta).ovf$
use_regex: true
register: app_ovf
- debug: var=app_ovf
- name: Parse OVF
xml:
path: "{{ app_ovf.files[0].path }}"
Expand All @@ -146,7 +141,6 @@
storage_domain_details.ovirt_storage_domains[0].critical_space_action_blocker|int *
1024 * 1024 * 1024 + 5 * 1024 * 1024 * 1024 }}
# +5G: 2xOVF_STORE, lockspace, metadata, configuration
- debug: var=required_size
- name: Remove unsuitable storage domain
ovirt_storage_domain:
host: "{{ he_host_name }}"
Expand All @@ -158,7 +152,6 @@
auth: "{{ ovirt_auth }}"
when: storage_domain_details.ovirt_storage_domains[0].available|int < required_size|int
register: remove_storage_domain_details
- debug: var=remove_storage_domain_details
- name: Check storage domain free space
fail:
msg: >-
Expand All @@ -178,5 +171,4 @@
auth: "{{ ovirt_auth }}"
when: storage_domain_details.ovirt_storage_domains[0].available|int >= required_size|int
register: otopi_storage_domain_details
- debug: var=otopi_storage_domain_details
...
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
environment: "{{ he_cmd_lang }}"
register: local_vm_ip
changed_when: true
- debug: var=local_vm_ip
- name: Fetch host facts
ovirt_host_info:
pattern: name={{ he_host_name }} status=up
Expand All @@ -17,19 +16,16 @@
until: host_result is succeeded and host_result.ovirt_hosts|length >= 1
retries: 50
delay: 10
- debug: var=host_result
- name: Fetch Cluster ID
set_fact: cluster_id="{{ host_result.ovirt_hosts[0].cluster.id }}"
- name: Fetch Cluster facts
ovirt_cluster_info:
auth: "{{ ovirt_auth }}"
register: cluster_facts
- debug: var=cluster_facts
- name: Fetch Datacenter facts
ovirt_datacenter_info:
auth: "{{ ovirt_auth }}"
register: datacenter_facts
- debug: var=datacenter_facts
- name: Fetch Cluster name
set_fact: cluster_name={{ cluster_facts.ovirt_clusters|json_query("[?id=='" + cluster_id + "'].name")|first }}
- name: Fetch Datacenter ID
Expand All @@ -51,7 +47,6 @@
name: ServerCPUList
version: "{{ cluster_version.major }}.{{ cluster_version.minor }}"
register: server_cpu_list
- debug: var=server_cpu_list
- name: Get cluster emulated machine list
ovirt_system_option_info:
name: ClusterEmulatedMachines
Expand All @@ -66,11 +61,9 @@
server_cpu_dict: "{{ server_cpu_dict | combine({item.split(':')[1]: item.split(':')[3]}) }}"
with_items: >-
{{ server_cpu_list['ovirt_system_option']['values'][0]['value'].split('; ')|list|difference(['']) }}
- debug: var=server_cpu_dict
- name: Convert CPU model name
set_fact:
cluster_cpu_model: "{{ server_cpu_dict[cluster_cpu.type] }}"
- debug: var=cluster_cpu_model
- name: Parse emulated_machine
set_fact:
emulated_machine: >-
Expand All @@ -81,7 +74,6 @@
pattern: name={{ he_storage_domain_name }} and datacenter={{ datacenter_name }}
auth: "{{ ovirt_auth }}"
register: storage_domain_details
- debug: var=storage_domain_details
- name: Add HE disks
ovirt_disk:
name: "{{ item.name }}"
Expand Down Expand Up @@ -135,19 +127,16 @@
he_sanlock_disk_details: "{{ add_disks.results[1] }}"
he_conf_disk_details: "{{ add_disks.results[2] }}"
he_metadata_disk_details: "{{ add_disks.results[3] }}"
- debug: var=add_disks
- name: Set default graphics protocols
set_fact:
he_graphic_protocols: [vnc, spice]
- name: Check if FIPS is enabled
command: sysctl -n crypto.fips_enabled
register: he_fips_enabled
- debug: var=he_fips_enabled
- name: Select graphic protocols
set_fact:
he_graphic_protocols: [spice]
when: he_fips_enabled.stdout == "1"
- debug: var=he_graphic_protocols
- name: Add VM
ovirt_vm:
state: stopped
Expand Down Expand Up @@ -177,10 +166,8 @@
mac_address: "{{ he_vm_mac_addr }}"
auth: "{{ ovirt_auth }}"
register: he_vm_details
- debug: var=he_vm_details
- name: Register external local VM uuid
shell: virsh -r domuuid {{ he_vm_name }}Local | head -1
environment: "{{ he_cmd_lang }}"
register: external_local_vm_uuid
changed_when: true
- debug: var=external_local_vm_uuid
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
register: db_vm_update
with_items:
- {field: 'origin', value: 6}
- debug: var=db_vm_update
- name: Insert Hosted Engine configuration disk uuid into Engine database
command: >-
psql -d engine -c
Expand All @@ -34,7 +33,6 @@
become_method: sudo
changed_when: true
register: db_conf_update
- debug: var=db_conf_update
- name: Fetch host SPM_ID
command: >-
psql -t -d engine -c
Expand All @@ -47,7 +45,6 @@
register: host_spm_id_out
- name: Parse host SPM_ID
set_fact: host_spm_id="{{ host_spm_id_out.stdout_lines|first|trim }}"
- debug: var=host_spm_id
- name: Restore original DisableFenceAtStartupInSec
shell: "engine-config -s DisableFenceAtStartupInSec=$(cat /root/DisableFenceAtStartupInSec.txt)"
environment: "{{ he_cmd_lang }}"
Expand Down
Loading

0 comments on commit 8f362f1

Please sign in to comment.