Fix error 601

Don't compare to literal True/False

Change-Id: I671978ac95de03d80b059d42f188e9fc9aecb4b4
This commit is contained in:
Riccardo Pittau 2020-09-01 11:23:25 +02:00
parent 1d5f0bbdc7
commit e4d0325b2f
27 changed files with 119 additions and 95 deletions

View File

@ -3,7 +3,6 @@ skip_list:
- '208' # File permissions not mentioned
- '301' # Commands should not change things if nothing needs doing
- '502' # All tasks should be named
- '601' # Don't compare to literal True/False
- '701' # meta/main.yml should contain relevant info
- '702' # Tags must contain lowercase letters and digits only
# NOTE(dtantsur): the following rules should likely stay excluded:

View File

@ -7,5 +7,5 @@
- role: ironic-enroll-dynamic
delegate_to: "{{ groups['target'][0] if groups['target'] is defined else 'localhost' }}"
- role: ironic-inspect-node
when: inspect_nodes | default('false') | bool == true
when: inspect_nodes | default('false') | bool
delegate_to: "{{ groups['target'][0] if groups['target'] is defined else 'localhost' }}"

View File

@ -26,5 +26,7 @@
become: no
connection: local
roles:
- { role: bifrost-configdrives-dynamic, when: provision_state == "available" and maintenance | bool != true }
- { role: bifrost-deploy-nodes-dynamic, when: provision_state == "available" and maintenance | bool != true }
- { role: bifrost-configdrives-dynamic,
when: provision_state == "available" and maintenance | bool }
- { role: bifrost-deploy-nodes-dynamic,
when: provision_state == "available" and maintenance | bool }

View File

@ -38,9 +38,11 @@
skip_items: []
register: node_info
roles:
- { role: bifrost-unprovision-node-dynamic, when: (provision_state == "active"
or provision_state == "deploy failed"
or provision_state == "error") and maintenance | bool != true }
- { role: bifrost-unprovision-node-dynamic,
when: (provision_state == "active"
or provision_state == "deploy failed"
or provision_state == "error")
and (not maintenance | bool) }
post_tasks:
- name: "Pull ironic facts until provision state available"
os_ironic_node_info:
@ -58,8 +60,10 @@
become: no
connection: local
roles:
- { role: bifrost-configdrives-dynamic, when: provision_state == "available" and maintenance | bool != true }
- { role: bifrost-deploy-nodes-dynamic, when: provision_state == "available" and maintenance | bool != true }
- { role: bifrost-configdrives-dynamic,
when: (provision_state == "available") and (not maintenance | bool) }
- { role: bifrost-deploy-nodes-dynamic,
when: (provision_state == "available") and (not maintenance | bool) }
post_tasks:
- name: "Pull ironic facts until provision state active"
os_ironic_node_info:

View File

@ -66,7 +66,7 @@
- name: "Write network Debian style interface template"
template: src=interfaces.j2 dest={{ variable_configdrive_location.path }}/{{ uuid }}/openstack/content/0000
when: write_interfaces_file | bool == true
when: write_interfaces_file | bool
- name: "Check if mkisofs is available"
command: mkisofs --help

View File

@ -22,7 +22,7 @@
- name: "Defined ssh_public_key_path - Error if ssh_public_key_path is not valid"
fail:
msg: "ssh_public_key_path is not valid."
when: test_ssh_public_key_path.stat.exists == false
when: not test_ssh_public_key_path.stat.exists | bool
delegate_to: localhost
- name: "Defined ssh_public_key_path - Read SSH public key in"

View File

@ -18,4 +18,4 @@
register: test_image_present
- name: "Create bootable image"
include: create_bootable_image.yml
when: test_image_present.stat.exists == true
when: test_image_present.stat.exists | bool

View File

@ -25,37 +25,39 @@
- name: "Test if image is present - {{ dib_imagename }}.{{ dib_imagetype | default('qcow2') }}"
stat: path={{ dib_imagename }}.{{ dib_imagetype | default('qcow2') }}
register: test_image_dib_present
when: test_image_present.stat.exists == false
when: not test_image_present.stat.exists
# Note(TheJulia): We need to explicitly test for initramfs in the case
# that the ironic-python-agent-ramdisk element is used to build the image.
- name: "Test if image is present - {{ dib_imagename }}.initramfs"
stat: path={{ dib_imagename }}.initramfs
register: test_image_initramfs_present
when: test_image_present.stat.exists == false and test_image_dib_present.stat.exists == false
when:
- not test_image_present.stat.exists
- not test_image_dib_present.stat.exists
- name: "Build tracing (-x) option for disk-image-create"
set_fact:
dib_trace_arg: "-x"
when: dib_trace == true
when: dib_trace | bool
- name: "Build uncompressed (-u) option for disk-image-create"
set_fact:
dib_uncompressed_arg: "-u"
when: dib_uncompressed == true
when: dib_uncompressed | bool
- name: "Build clear environment (-c) option for disk-image-create"
set_fact:
dib_clearenv_arg: "-c"
when: dib_clearenv == true
when: dib_clearenv | bool
- name: "Build no tmpfs (--no-tmpfs) option for disk-image-create"
set_fact:
dib_notmpfs_arg: "--no-tmpfs"
when: dib_notmpfs == true
when: dib_notmpfs | bool
- name: "Build offline (--offline) option for disk-image-create"
set_fact:
dib_offline_arg: "--offline"
when: dib_offline == true
when: dib_offline | bool
- name: "Build skip default base element (-n) option for disk-image-create"
set_fact:
dib_skipbase_arg: "-n"
when: dib_skipbase == true
when: dib_skipbase | bool
- name: "Build architecture (-a) option for disk-image-create"
set_fact:
dib_arch_arg: "-a {{ dib_arch }}"
@ -187,11 +189,11 @@
package:
name: debootstrap
state: present
when: >
test_image_present.stat.exists == false
and test_image_dib_present.stat.exists == false
and test_image_initramfs_present.stat.exists == false
and ("debian" in dib_os_element or "ubuntu" in dib_os_element)
when:
- not test_image_present.stat.exists
- not test_image_dib_present.stat.exists
- not test_image_initramfs_present.stat.exists
- ("debian" in dib_os_element or "ubuntu" in dib_os_element)
- name: "Initiate image build"
command: disk-image-create {{ dib_arglist }}
environment: "{{ dib_env_vars_final | combine(bifrost_venv_env) }}"

View File

@ -79,7 +79,7 @@
version: "{{ reqs_git_branch }}"
update: "{{ update_repos | bool }}"
clone: yes
when: copy_from_local_path | bool == false
when: not copy_from_local_path | bool
- name: copy requirements from local path
command: cp -a {{ reqs_git_url }} {{ reqs_git_folder }} creates={{ reqs_git_folder }}

View File

@ -57,9 +57,9 @@
- name: "Place sgabios.bin"
command: cp /usr/share/misc/sgabios.bin /usr/share/qemu/sgabios.bin
when: >
test_sgabios_qemu == false and
test_sgabios_misc == true
when:
- not test_sgabios_qemu | bool
- test_sgabios_misc | bool
# NOTE(TheJulia): In order to prevent conflicts, stop
# dnsmasq to prevent conflicts with libvirt restarting.

View File

@ -31,7 +31,7 @@
owner: root
group: root
mode: 0644
when: inventory_dhcp | bool == true
when: inventory_dhcp | bool
become: yes
- name: "Setup DNS address for nodes."
@ -41,7 +41,7 @@
owner: root
group: root
mode: 0644
when: inventory_dns | bool == true
when: inventory_dns | bool
become: yes
- name: "Restarting dnsmasq"
@ -49,7 +49,7 @@
name: dnsmasq
state: restarted
become: yes
when: (inventory_dhcp | bool == true) or (inventory_dns | bool == true)
when: inventory_dhcp | bool or inventory_dns | bool
- name: "Deploy to hardware - Using custom instance_info."
openstack.cloud.baremetal_node_action:
@ -76,7 +76,9 @@
- name: "Error if deploy_image is not present, and instance_info is not defined"
fail: msg="The user-defined deploy_image, which is the image to be written to the remote node(s) upon deployment, was not found. Cannot proceed."
when: instance_info is not defined and test_deploy_image.stat.exists | bool == false
when:
- instance_info is not defined
- not test_deploy_image.stat.exists
- name: "Deploy to hardware - bifrost default"
openstack.cloud.baremetal_node_action:

View File

@ -18,9 +18,9 @@
msg: >
noauth_mode and enable_keystone are mutually exclusive options.
Please set one to "false".
when: >
noauth_mode | bool == true and enable_keystone is defined and
enable_keystone | bool == true
when:
- noauth_mode | bool
- enable_keystone | bool
- block:
- name: "Ask systemd to reload configuration"
@ -161,7 +161,8 @@
- name: "Populate keystone for Bifrost"
include: keystone_setup.yml
when: enable_keystone is defined and enable_keystone | bool == true
when:
- enable_keystone | bool
# NOTE(pas-ha) needed to e.g. pick up new interfaces after libvirt install
- name: "Refresh facts"
@ -186,16 +187,16 @@
- name: "Create ironic DB Schema"
command: ironic-dbsync --config-file /etc/ironic/ironic.conf create_schema
environment: "{{ bifrost_venv_env }}"
when: >
ironic.database.host == 'localhost' and
test_created_db.changed | bool == true
when:
- ironic.database.host == 'localhost'
- test_created_db.changed | bool
- name: "Upgrade ironic DB Schema"
command: ironic-dbsync --config-file /etc/ironic/ironic.conf upgrade
environment: "{{ bifrost_venv_env }}"
when: >
ironic.database.host != 'localhost' or
test_created_db.changed | bool == false
not test_created_db.changed | bool
- name: "Create service folder"
file:
@ -205,7 +206,7 @@
- name: "Install ironic-inspector to permit use of inspection interface"
include: inspector_bootstrap.yml
when: enable_inspector | bool == true
when: enable_inspector | bool
- name: "Get ironic-api & ironic-conductor install location"
shell: echo $(dirname $(which ironic-api))
@ -249,7 +250,7 @@
owner: "root"
group: "root"
mode: 0755
when: inventory_dhcp | bool == true
when: inventory_dhcp | bool
- name: "Setup Inventory DHCP Hosts Directory"
file:
path: "/etc/dnsmasq.d/bifrost.dhcp-hosts.d"
@ -257,19 +258,19 @@
owner: "root"
group: "root"
mode: 0755
when: inventory_dhcp | bool == true
when: inventory_dhcp | bool
- name: "Retrieve interface IP informations"
set_fact:
itf_infos: "{{ internal_interface }}"
dhcp_netaddr: "{{ dhcp_pool_start }}/{{ dhcp_static_mask }}"
when: include_dhcp_server | bool == true
when: include_dhcp_server | bool
- name: "Compute interface and DHCP network informations"
set_fact:
itf_netaddr1: "{{ itf_infos['address'] }}/{{ itf_infos['netmask'] }}"
itf_netaddr2: "{{ itf_infos['network'] }}/{{ itf_infos['netmask'] }}"
itf_broadcast: "{{ itf_infos['broadcast'] }}/{{ itf_infos['netmask'] }}"
dhcp_netaddr: "{{ dhcp_netaddr | ipaddr('network') }}/{{ dhcp_static_mask }}"
when: include_dhcp_server | bool == true
when: include_dhcp_server | bool
- name: "Validate interface network addresses"
fail:
msg: >
@ -304,7 +305,7 @@
dhcp_end_ip: "{{ dhcp_pool_end.split('.')[-1] }}"
dhcp_netaddr: "{{ itf_netaddr1 | ipaddr('network') }}"
when:
- include_dhcp_server | bool == true
- include_dhcp_server | bool
- itf_netaddr2 | ipaddr('network') != dhcp_netaddr | ipaddr('network')
# Note(olivierbourdon38): we could do much more complex network
# computation to derive exact (or way closer to exact) range for
@ -314,28 +315,30 @@
dhcp_pool_start: "{{ '.'.join(dhcp_netaddr.split('.')[0:-1]) }}.{{ dhcp_start_ip }}"
dhcp_pool_end: "{{ '.'.join(dhcp_netaddr.split('.')[0:-1]) }}.{{ dhcp_end_ip }}"
when:
- include_dhcp_server | bool == true
- include_dhcp_server | bool
- itf_netaddr2 | ipaddr('network') != dhcp_netaddr | ipaddr('network')
- name: "Deploy dnsmasq configuration file"
template: src=dnsmasq.conf.j2 dest=/etc/dnsmasq.conf
when: include_dhcp_server | bool == true
when: include_dhcp_server | bool
# NOTE(Shrews) When testing, we want to use our custom dnsmasq.conf file,
# not the one supplied by libvirt.
- name: "Look for libvirt dnsmasq config"
stat: path=/etc/dnsmasq.d/libvirt-bin
register: test_libvirt_dnsmasq
when: include_dhcp_server | bool == true
when: include_dhcp_server | bool
- name: "Disable libvirt dnsmasq config"
command: mv /etc/dnsmasq.d/libvirt-bin /etc/dnsmasq.d/libvirt-bin~
when: >
include_dhcp_server | bool == true and
test_libvirt_dnsmasq.stat.exists | bool == true and
testing | bool == true
when:
- include_dhcp_server | bool
- test_libvirt_dnsmasq.stat.exists
- testing | bool
- name: "Deploy nginx configuration file for serving HTTP requests"
template: src=nginx.conf.j2 dest=/etc/nginx/nginx.conf
- name: "Download Ironic Python Agent kernel & image"
include: download_ipa_image.yml
when: create_ipa_image | bool == false and download_ipa | bool == true
when:
- not create_ipa_image | bool
- download_ipa | bool
- name: "Download cirros to use for deployment if requested"
get_url:
url: "{{ cirros_deploy_image_upstream_url }}"
@ -343,7 +346,7 @@
owner: ironic
group: ironic
mode: 0644
when: use_cirros | bool == true
when: use_cirros | bool
- name: "Create a checksum file for cirros"
shell: md5sum {{ deploy_image_filename }} > {{ deploy_image_filename }}.CHECKSUMS
args:

View File

@ -42,7 +42,7 @@
- name: "Download ipxe files if asked"
include: get_ipxe.yml
when: download_ipxe | bool == true
when: download_ipxe | bool
- name: "Copy iPXE image into place"
copy:
@ -88,7 +88,7 @@
at the {{ ipxe_dir }} location. Please place this file or consider
re-running with download_ipxe set to a value of true.
when:
- test_ipxe_efi_binary_path.stat.exists | bool == false
- not test_ipxe_efi_binary_path.stat.exists
- name: "Copy iPXE EFI image into {{ http_boot_folder }}/"
copy:
@ -108,7 +108,7 @@
mode: 0644
remote_src: true
when: enable_uefi_ipxe | bool == true
when: enable_uefi_ipxe | bool
# Similar logic to below can be utilized to retrieve files
- name: "Determine if folder exists, else create and populate folder."
@ -117,7 +117,7 @@
- name: "Create master_images folder"
file: name="{{ ironic_tftp_master_path }}" state=directory owner=ironic group=ironic
when: test_master_images.stat.exists == false
when: not test_master_images.stat.exists
# TODO(TheJulia): The pxelinux folder is statically coded in ironic.
# For now, we need to use it, but we can patch that.
@ -128,4 +128,4 @@
owner: ironic
group: ironic
mode: 0644
when: enable_inspector | bool == true
when: enable_inspector | bool

View File

@ -77,7 +77,7 @@
delay: 10
when:
- update_ipa | bool or
test_ipa_kernel_present.stat.exists == false
not test_ipa_kernel_present.stat.exists
- name: "Test if IPA image is present"
stat: path={{ ipa_ramdisk }}
@ -141,4 +141,4 @@
delay: 10
when:
- update_ipa | bool or
test_ipa_image_present.stat.exists == false
not test_ipa_image_present.stat.exists

View File

@ -51,4 +51,4 @@
delay: 10
loop:
- "{{ ipxe_efi_binary }}"
when: enable_uefi_ipxe | bool == true
when: enable_uefi_ipxe | bool

View File

@ -94,7 +94,7 @@
- name: "Populate keystone for ironic-inspector "
include: keystone_setup_inspector.yml
when: enable_keystone is defined and enable_keystone | bool == true
when: enable_keystone | bool
- name: "Inspector - Place Configuration"
template:

View File

@ -44,7 +44,7 @@
package: ironic-python-agent-builder
sourcedir: "{{ ipa_builder_git_folder }}"
source_install: true
when: install_dib | bool == true
when: install_dib | bool
# NOTE(mgoddard): IPA-builder has a dependency on diskimage-builder. Install
# DIB last to ensure it is installed from source rather than PyPI.
@ -55,7 +55,7 @@
package: diskimage-builder
sourcedir: "{{ dib_git_folder }}"
source_install: true
when: install_dib | bool == true
when: install_dib | bool
- name: "sushy - Install"
include_role:
@ -106,11 +106,11 @@
- name: "Install ironic-inspector to permit use of inspection interface"
include_tasks: inspector_install.yml
when: enable_inspector | bool == true
when: enable_inspector | bool
- name: "Install ironic-staging-drivers"
include_tasks: staging_install.yml
when: staging_drivers_include | bool == true
when: staging_drivers_include | bool
- name: "Install openstacksdk"
include_role:

View File

@ -58,19 +58,19 @@
- name: "Install Ironic deps"
include: install.yml
when: skip_package_install | bool != True
when: not skip_package_install | bool
- name: "Bootstrap Ironic"
include: bootstrap.yml
when: skip_bootstrap | bool != True
when: not skip_bootstrap | bool
- name: "Start Ironic services"
include: start.yml
when: skip_start | bool != True
when: not skip_start | bool
- name: "Perform online data migrations"
include: migrations.yml
when: skip_migrations | bool != True
when: not skip_migrations | bool
- name: "Validate deployment"
include: validate.yml

View File

@ -8,7 +8,7 @@
- name: "Defined ssh_private_key_path - Error if ssh_private_key_path is not valid"
fail:
msg: "ssh_private_key_path is not valid."
when: test_ssh_private_key_path.stat.exists == false
when: not test_ssh_private_key_path.stat.exists
delegate_to: localhost
- name: "Defined ssh_private_key_path - Read SSH private key in"

View File

@ -33,7 +33,7 @@
- name: "start ironic-inspector"
include: inspector_start.yml
when: enable_inspector | bool == true
when: enable_inspector | bool
- name: "Start ironic-conductor"
service: name=ironic-conductor state=started enabled=yes
@ -62,7 +62,7 @@
service: name={{ item }} state=restarted enabled=yes
loop:
- dnsmasq
when: include_dhcp_server | bool == true
when: include_dhcp_server | bool
- name: "Send services a reload signal"
service: name={{ item }} state=reloaded
@ -72,4 +72,4 @@
- name: "Send services a force-reload signal"
service: name=dnsmasq state=restarted
when: include_dhcp_server | bool == true
when: include_dhcp_server | bool

View File

@ -140,10 +140,10 @@
--bootstrap-internal-url="{{ keystone.bootstrap.internal_url | default(keystone_private_url) | default(keystone_api_url) }}"
--bootstrap-region-id="{{ keystone.bootstrap.region_name }}"
environment: "{{ bifrost_venv_env }}"
when: >
test_created_keystone_db.changed | bool == true and
keystone.bootstrap.enabled | bool == true and
keystone.database.host == 'localhost'
when:
- test_created_keystone_db.changed
- keystone.bootstrap.enabled | bool
- keystone.database.host == 'localhost'
- name: "Reserve keystone admin port"
sysctl:

View File

@ -35,15 +35,21 @@
- name: "Install Keystone"
include: install.yml
when: enable_keystone is defined and enable_keystone |bool == True and skip_package_install | bool != True
when:
- enable_keystone | bool
- not skip_package_install | bool
- name: "Bootstrap Keystone"
include: bootstrap.yml
when: enable_keystone is defined and enable_keystone |bool == True and skip_bootstrap | bool != True
when:
- enable_keystone | bool
- not skip_bootstrap | bool
- name: "Start Keystone services"
include: start.yml
when: enable_keystone is defined and enable_keystone |bool == True and skip_start | bool != True
when:
- enable_keystone | bool
- not skip_start | bool
- name: "Change the bootstrap password from the static value on upgrade"
os_user:

View File

@ -30,7 +30,7 @@
- upper_constraints_file | length > 0
# NOTE(dtantsur): constraining does not work correctly correctly with
# source installation if the package itself is in constraints.
- source_install | bool == false
- not source_install | bool
- name: "Install {{ package }} package from pip using virtualenv"
pip:

View File

@ -30,9 +30,13 @@
update: "{{ update_repos | bool }}"
clone: yes
loop: "{{ bifrost_install_sources }}"
when: copy_from_local_path | bool == false and item.source_install | default(true) | bool
when:
- not copy_from_local_path | bool
- item.source_install | default(true) | bool
- name: "Copy from local path"
command: cp -a {{ item.git_url }} {{ item.git_folder }} creates={{ item.git_folder }}
loop: "{{ bifrost_install_sources }}"
when: copy_from_local_path | bool == true and item.source_install | default(true) | bool
when:
- copy_from_local_path | bool
- item.source_install | default(true) | bool

View File

@ -36,19 +36,21 @@
when: ipv4_address is defined
- name: "Pause before asking for keyscan, to avoid races"
pause: minutes=3
when: multinode_testing | bool == true
when: multinode_testing | bool
- name: >
Re-check SSH connectivity prior to proceeding with multi-node testing
wait_for:
state: started
port: 22
host: "{{ ipv4_address }}"
when: ipv4_address is defined and multinode_testing | bool == true
when:
- ipv4_address is defined
- multinode_testing | bool
- name: >
Additional SSH startup pause when performing multi-node testing
pause:
seconds: "{{ node_ssh_pause }}"
when: multinode_testing | bool == true
when: multinode_testing | bool
- name: "Add testvm hosts from SSH known_hosts file."
shell: ssh-keyscan "{{ ipv4_address }}" >> "{{ ansible_env.HOME }}/.ssh/known_hosts"
when: ipv4_address is defined

View File

@ -26,7 +26,7 @@
owner: root
group: root
mode: 0644
when: inventory_dhcp | bool == true
when: inventory_dhcp | bool
become: yes
- name: "Setup DNS address for nodes."
template:
@ -35,14 +35,14 @@
owner: root
group: root
mode: 0644
when: inventory_dns | bool == true
when: inventory_dns | bool
become: yes
- name: "Sending dnsmasq HUP"
# Note(TheJulia): We need to actually to send a hup signal directly as
# Ansible's reloaded state does not pass through to the init script.
command: killall -HUP dnsmasq
become: yes
when: (inventory_dhcp | bool == true) or (inventory_dns | bool == true)
when: inventory_dhcp | bool or inventory_dns | bool
- name: "Execute node introspection"
openstack.cloud.baremetal_inspect:

View File

@ -178,8 +178,8 @@
become: yes
gather_facts: yes
vars:
inventory_dhcp: "{{ inventory_dhcp | bool == true }}"
inventory_dhcp_static_ip: "{{ inventory_dhcp_static_ip | bool == true }}"
inventory_dhcp: "{{ inventory_dhcp | bool }}"
inventory_dhcp_static_ip: "{{ inventory_dhcp_static_ip | bool }}"
roles:
- { role: bifrost-test-dhcp, when: inventory_dhcp | bool }
environment: