Merge "ansible-lint: fix error 602"

This commit is contained in:
Zuul 2020-09-01 09:12:16 +00:00 committed by Gerrit Code Review
commit feff8e9de8
11 changed files with 50 additions and 35 deletions

View File

@ -4,7 +4,6 @@ skip_list:
- '301' # Commands should not change things if nothing needs doing
- '502' # All tasks should be named
- '601' # Don't compare to literal True/False
- '602' # Don't compare to empty string
- '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

@ -59,7 +59,7 @@
set_fact:
ironic_url: "{{ openstack_cloud.baremetal_endpoint_override }}"
when:
- ironic_url | default("") == ""
- not ironic_url | default("")
- openstack_cloud is defined
- openstack_cloud.baremetal_endpoint_override is defined
@ -67,5 +67,5 @@
set_fact:
ironic_url: "http://localhost:6385/"
when:
- ironic_url | default("") == ""
- not ironic_url | default("")
- noauth_mode | bool

View File

@ -107,7 +107,9 @@
- name: "Build packages (-p) option for disk-image-create"
set_fact:
dib_packages_arg: "-p {{ dib_packages }}"
when: dib_packages is defined and dib_packages != ""
when:
- dib_packages is defined
- dib_packages | length > 0
- name: "Set default of Debian Buster if building debian and not explicitly set, overwride with dib_os_release setting"
set_fact:
dib_os_release: "buster"
@ -147,7 +149,7 @@
dib_env_vars_final: "{{ dib_env_vars_final | combine({'DIB_BLOCK_DEVICE_CONFIG': dib_partitioning}) }}"
when:
- dib_partitioning is defined
- dib_partitioning|length > 0
- dib_partitioning | length > 0
- name: "Set partitioning information if set"
slurp:
src: "{{ partitioning_file }}"
@ -212,7 +214,9 @@
mode: u=rwX,g=rX,o=rX
recurse: yes
state: directory
when: http_boot_folder is defined and http_boot_folder != ''
when:
- http_boot_folder is defined
- http_boot_folder | length > 0
- name: "Restore proper context on created data for http_boot"
command: restorecon -R {{ http_boot_folder }}
when: (ansible_os_family == 'RedHat' or ansible_os_family == 'Suse') and

View File

@ -134,22 +134,18 @@
dest: "{{ baremetal_nodes_json }}"
content: "{{ {'nodes': testvm_nodes_json} | to_nice_json }}"
- name: >
"Set file permissions such that the baremetal data file
can be read by the user executing Ansible"
- name: Ensure the baremetal data file can be read by the user executing Ansible
file:
path: "{{ baremetal_json_file }}"
owner: "{{ ansible_env.SUDO_USER }}"
when: >
ansible_env.SUDO_USER is defined and
baremetal_json_file != ""
when:
- ansible_env.SUDO_USER is defined
- baremetal_json_file | length > 0
- name: >
"Set file permissions such that the nodes json file
can be read by the user executing Ansible"
- name: Ensure the nodes json file can be read by the user executing Ansible
file:
path: "{{ baremetal_nodes_json }}"
owner: "{{ ansible_env.SUDO_USER }}"
when: >
ansible_env.SUDO_USER is defined and
baremetal_nodes_json != ""
when:
- ansible_env.SUDO_USER is defined
- baremetal_nodes_json | length > 0

View File

@ -181,7 +181,7 @@
loop:
- "{{ ironic_log_dir | default('') }}"
- "{{ ironic_agent_deploy_logs_local_path | default('') }}"
when: item != ""
when: item | length > 0
- name: "Create ironic DB Schema"
command: ironic-dbsync --config-file /etc/ironic/ironic.conf create_schema
@ -432,4 +432,6 @@
ansible_selinux.status == 'enabled' and ansible_selinux.mode == "enforcing"
- name: "Configure remote logging"
template: src=10-rsyslog-remote.conf.j2 dest=/etc/rsyslog.d/10-rsyslog-remote.conf
when: remote_syslog_server is defined and remote_syslog_server != ""
when:
- remote_syslog_server is defined
- remote_syslog_server | length > 0

View File

@ -51,11 +51,13 @@
when: not ipa_kernel_checksum_result is failed
- fail:
msg: "Failed to extract checksum for {{ ipa_kernel_upstream_url | basename }}"
when: not ipa_kernel_checksum_result is failed and parsed_ipa_kernel_checksum.stdout == ""
when:
- not ipa_kernel_checksum_result is failed
- not parsed_ipa_kernel_checksum.stdout
- set_fact:
ipa_kernel_checksum: "{{ ipa_kernel_upstream_checksum_algo }}:{{ parsed_ipa_kernel_checksum.stdout }}"
when: not ipa_kernel_checksum_result is failed
when: ipa_kernel_upstream_checksum_url != ""
when: ipa_kernel_upstream_checksum_url | length > 0
- name: "Download IPA kernel"
get_url:
@ -73,7 +75,9 @@
(ipa_kernel_download_done is failed)
retries: 5
delay: 10
when: update_ipa | bool or test_ipa_kernel_present.stat.exists == false
when:
- update_ipa | bool or
test_ipa_kernel_present.stat.exists == false
- name: "Test if IPA image is present"
stat: path={{ ipa_ramdisk }}
@ -111,11 +115,13 @@
when: not ipa_ramdisk_checksum_result is failed
- fail:
msg: "Failed to extract checksum for {{ ipa_ramdisk_upstream_url | basename }}"
when: not ipa_ramdisk_checksum_result is failed and parsed_ipa_ramdisk_checksum.stdout == ""
when:
- not ipa_ramdisk_checksum_result is failed
- not parsed_ipa_ramdisk_checksum.stdout
- set_fact:
ipa_ramdisk_checksum: "{{ ipa_ramdisk_upstream_checksum_algo }}:{{ parsed_ipa_ramdisk_checksum.stdout }}"
when: not ipa_ramdisk_checksum_result is failed
when: ipa_ramdisk_upstream_checksum_url != ""
when: ipa_ramdisk_upstream_checksum_url | length > 0
- name: "Download IPA image"
get_url:
@ -133,4 +139,6 @@
(ipa_ramdisk_download_done is failed and ipa_ramdisk_download_done.status_code is defined and ipa_ramdisk_download_done.status_code == 404)
retries: 5
delay: 10
when: update_ipa | bool or test_ipa_image_present.stat.exists == false
when:
- update_ipa | bool or
test_ipa_image_present.stat.exists == false

View File

@ -24,14 +24,14 @@
no-bios
{%- if "ilo" in enabled_hardware_types -%},ilo{%- endif -%}
{%- if "redfish" in enabled_hardware_types -%},redfish{%- endif -%}
when: enabled_bios_interfaces == ""
when: not enabled_bios_interfaces
- name: "Configure boot interfaces if required"
set_fact:
enabled_boot_interfaces: >-
ipxe,pxe
{%- if "ilo" in enabled_hardware_types -%},ilo-virtual-media{%- endif -%}
when: enabled_boot_interfaces == ""
when: not enabled_boot_interfaces
- name: "Configure management interfaces if required"
set_fact:
@ -40,7 +40,7 @@
{%- if "ilo" in enabled_hardware_types -%},ilo{%- endif -%}
{%- if "ipmi" in enabled_hardware_types -%},ipmitool{%- endif -%}
{%- if "redfish" in enabled_hardware_types -%},redfish{%- endif -%}
when: enabled_management_interfaces == ""
when: not enabled_management_interfaces
- name: "Configure power interfaces if required"
set_fact:
@ -50,4 +50,4 @@
{%- if "ipmi" in enabled_hardware_types -%},ipmitool{%- endif -%}
{%- if "redfish" in enabled_hardware_types -%},redfish{%- endif -%}
{%- if enable_credential_less_deploy|bool -%},agent{%- endif -%}
when: enabled_power_interfaces == ""
when: not enabled_power_interfaces

View File

@ -113,7 +113,7 @@
loop:
- "{{ inspector_log_dir | default('') }}"
- "{{ inspector_ramdisk_logs_local_path | default('') }}"
when: item != ""
when: item | length > 0
- name: "Upgrade inspector DB Schema"
command: ironic-inspector-dbsync --config-file /etc/ironic-inspector/inspector.conf upgrade
become: true

View File

@ -19,7 +19,9 @@
- name: "Ensure rsyslog is running with current config"
service: name=rsyslog state=restarted
when: remote_syslog_server is defined and remote_syslog_server != ""
when:
- remote_syslog_server is defined
- remote_syslog_server | length > 0
- name: "Start database service"
service: name={{ mysql_service_name }} state=started enabled=yes

View File

@ -48,7 +48,9 @@
command: baremetal conductor list -f value -c Hostname
environment: "{{ testing_env | combine(bifrost_venv_env) }}"
register: conductor_list
failed_when: conductor_list.rc != 0 or conductor_list.stdout | trim == ""
failed_when:
- conductor_list.rc != 0 or
not conductor_list.stdout
retries: 6
delay: 5
until: conductor_list is not failed

View File

@ -19,13 +19,15 @@
- name: "Check that sourcedir is provided with source_install"
fail:
msg: Source installation of requires sourcedir to be provided
when: source_install | bool and sourcedir | default('') == ''
when:
- source_install | bool
- not sourcedir
- name: "Set extra_args if upper_constraints_file is defined"
set_fact:
constraints_extra_args: "{{ extra_args | default('') }} -c {{ upper_constraints_file }}"
when:
- upper_constraints_file != ''
- 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