From 0eee2d04835a84598aca2cf8bfb5cb1025ea8b76 Mon Sep 17 00:00:00 2001 From: Riccardo Pittau Date: Tue, 25 Aug 2020 10:29:46 +0200 Subject: [PATCH] ansible-lint: fix error 206 Variables should have spaces before and after: {{ var_name }} Change-Id: I7e8616e835bbbe7500b0aae5b1b985ef5d471403 --- .ansible-lint | 1 - playbooks/cleanup-deployment-images.yaml | 6 +- .../tasks/main.yml | 6 +- .../tasks/create_bootable_image.yml | 26 +++---- .../bifrost-create-dib-image/tasks/main.yml | 76 +++++++++---------- .../tasks/prepare_libvirt.yml | 2 +- .../tasks/main.yml | 2 +- .../tasks/create_tftpboot.yml | 4 +- .../tasks/inspector_bootstrap.yml | 2 +- .../tasks/main.yml | 2 +- .../tasks/bootstrap.yml | 6 +- .../roles/bifrost-test-dhcp/tasks/main.yml | 4 +- .../ironic-enroll-dynamic/tasks/main.yml | 2 +- playbooks/test-bifrost.yaml | 4 +- 14 files changed, 71 insertions(+), 72 deletions(-) diff --git a/.ansible-lint b/.ansible-lint index 97d41a14d..e8541068c 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,6 +1,5 @@ skip_list: # FIXME: gradually fix and remove these exclusions: - - '206' # Variables should have spaces before and after: {{ var_name }} - '208' # File permissions not mentioned - '301' # Commands should not change things if nothing needs doing - '502' # All tasks should be named diff --git a/playbooks/cleanup-deployment-images.yaml b/playbooks/cleanup-deployment-images.yaml index a5748aa26..ba62de028 100644 --- a/playbooks/cleanup-deployment-images.yaml +++ b/playbooks/cleanup-deployment-images.yaml @@ -5,6 +5,6 @@ become: yes gather_facts: yes tasks: - - file: path="{{ironic_tftp_master_path}}" state=absent - - file: path="{{ipa_kernel}}" state=absent - - file: path="{{ipa_ramdisk}}" state=absent + - file: path="{{ ironic_tftp_master_path }}" state=absent + - file: path="{{ ipa_kernel }}" state=absent + - file: path="{{ ipa_ramdisk }}" state=absent diff --git a/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml b/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml index 36a2521e4..a349ea541 100644 --- a/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-configdrives-dynamic/tasks/main.yml @@ -103,13 +103,13 @@ - name: "Make config drive files" become: yes - command: "{{iso_gen_utility}} -R -V config-2 -o {{http_boot_folder}}/configdrive-{{ uuid }}.iso {{ variable_configdrive_location.path }}/{{ uuid }}" + command: "{{ iso_gen_utility }} -R -V config-2 -o {{ http_boot_folder }}/configdrive-{{ uuid }}.iso {{ variable_configdrive_location.path }}/{{ uuid }}" - name: "Make config drive files base64 encoded and gzip compressed" become: yes shell: | set -o pipefail - gzip -c {{http_boot_folder}}/configdrive-{{ uuid }}.iso | base64 > {{http_boot_folder}}/configdrive-{{ uuid }}.iso.gz + gzip -c {{ http_boot_folder }}/configdrive-{{ uuid }}.iso | base64 > {{ http_boot_folder }}/configdrive-{{ uuid }}.iso.gz args: executable: /bin/bash @@ -117,7 +117,7 @@ become: yes file: state: absent - name: "{{http_boot_folder}}/configdrive-{{ uuid }}.iso" + name: "{{ http_boot_folder }}/configdrive-{{ uuid }}.iso" - name: "Cleanup configdrive temp folder" become: yes diff --git a/playbooks/roles/bifrost-create-bootable-image/tasks/create_bootable_image.yml b/playbooks/roles/bifrost-create-bootable-image/tasks/create_bootable_image.yml index 2774ced55..73e245885 100644 --- a/playbooks/roles/bifrost-create-bootable-image/tasks/create_bootable_image.yml +++ b/playbooks/roles/bifrost-create-bootable-image/tasks/create_bootable_image.yml @@ -14,18 +14,18 @@ # limitations under the License. --- - name: "Extract the raw disk image" - command: qemu-img convert -O raw "{{deploy_image}}" "{{deploy_image}}.raw" + command: qemu-img convert -O raw "{{ deploy_image }}" "{{ deploy_image }}.raw" - name: "Copy image however with 32k of empty space at the beginning of the file." - command: dd if="{{deploy_image}}.raw" of="{{deploy_image}}.bootimg" seek=64 + command: dd if="{{ deploy_image }}.raw" of="{{ deploy_image }}.bootimg" seek=64 - name: "Create partition table lining up with the copied file's contents." - shell: echo '32;' | sfdisk "{{deploy_image}}.bootimg" -uB -f # noqa 306 + shell: echo '32;' | sfdisk "{{ deploy_image }}.bootimg" -uB -f # noqa 306 - name: "Allocate one of two loopbacks" command: losetup -f register: stored_value_loopback_alpha - name: "Create loopback connetion to new image file" - command: losetup "{{stored_value_loopback_alpha.stdout}}" "{{deploy_image}}.bootimg" + command: losetup "{{ stored_value_loopback_alpha.stdout }}" "{{ deploy_image }}.bootimg" - name: "Force partition table to be re-read" - command: kpartx -v -a "{{stored_value_loopback_alpha.stdout}}" + command: kpartx -v -a "{{ stored_value_loopback_alpha.stdout }}" # Using second loopback as for some reason /dev/mapper does not translate into a chroot cleanly when devfs is mounted - name: "Allocate second loopback pointing to the initial partition" command: losetup -f @@ -33,7 +33,7 @@ - name: "Bind second loopback to the first partition" shell: | set -o pipefail - losetup "{{stored_value_loopback_beta.stdout}}" /dev/mapper/$(echo "{{stored_value_loopback_alpha.stdout}}" | cut -f3 -d '/')p1 + losetup "{{ stored_value_loopback_beta.stdout }}" /dev/mapper/$(echo "{{ stored_value_loopback_alpha.stdout }}" | cut -f3 -d '/')p1 executable: /bin/bash # TODO parameterize folder name/location - name: "Ensure we have a location to mount the disk to" @@ -41,7 +41,7 @@ # NOTE(dtantsur): skipping ansible-lint 303 because the mount module does not # support temporary mounts: https://github.com/ansible-collections/ansible.posix/issues/84 - name: "Mount volume on /mnt/bootimg" - command: mount "{{stored_value_loopback_beta.stdout}}" /mnt/bootimg # noqa 303 + command: mount "{{ stored_value_loopback_beta.stdout }}" /mnt/bootimg # noqa 303 - name: "Bind /sys into /mnt/bootimg/sys" command: mount -t sysfs sysfs /mnt/bootimg/sys # noqa 303 - name: "Bind /proc into /mnt/bootimg/proc" @@ -53,7 +53,7 @@ - name: "Disable Grub Prober" shell: echo 'GRUB_TERMINAL="serial console"' >>/etc/default/grub - name: "Run the grub-install tool" - command: chroot /mnt/bootimg grub-install --boot-directory=/boot --modules="biosdisk part_msdos" "{{stored_value_loopback_alpha.stdout}}" + command: chroot /mnt/bootimg grub-install --boot-directory=/boot --modules="biosdisk part_msdos" "{{ stored_value_loopback_alpha.stdout }}" - name: "Unlink /dev/bootimg/dev" command: umount /mnt/bootimg/dev - name: "Unlink /dev/bootimg/proc" @@ -63,12 +63,12 @@ - name: "Unmount image" command: umount /mnt/bootimg - name: "Detach second loop device" - command: losetup -d "{{stored_value_loopback_beta.stdout}}" + command: losetup -d "{{ stored_value_loopback_beta.stdout }}" - name: "Remove partition map" - command: kpartx -v -d "{{stored_value_loopback_alpha.stdout}}" + command: kpartx -v -d "{{ stored_value_loopback_alpha.stdout }}" - name: "Detach first loop device" - command: losetup -d "{{stored_value_loopback_alpha.stdout}}" + command: losetup -d "{{ stored_value_loopback_alpha.stdout }}" - name: "Move image to .oldimg" - command: mv "{{deploy_image}}" "{{deploy_image}}.oldimg" + command: mv "{{ deploy_image }}" "{{ deploy_image }}.oldimg" - name: "Move new image into place" - command: mv "{{deploy_image}}.bootimg" "{{deploy_image}}" + command: mv "{{ deploy_image }}.bootimg" "{{ deploy_image }}" diff --git a/playbooks/roles/bifrost-create-dib-image/tasks/main.yml b/playbooks/roles/bifrost-create-dib-image/tasks/main.yml index a23b77acc..8578ecf24 100644 --- a/playbooks/roles/bifrost-create-dib-image/tasks/main.yml +++ b/playbooks/roles/bifrost-create-dib-image/tasks/main.yml @@ -58,55 +58,55 @@ when: dib_skipbase == true - name: "Build architecture (-a) option for disk-image-create" set_fact: - dib_arch_arg: "-a {{dib_arch}}" + dib_arch_arg: "-a {{ dib_arch }}" when: dib_arch is defined - name: "Build image name (-o) option for disk-image-create" set_fact: - dib_imagename_arg: "-o {{dib_imagename}}" + dib_imagename_arg: "-o {{ dib_imagename }}" when: dib_imagename is defined - name: "Build image type (-t) option for disk-image-create" set_fact: - dib_imagetype_arg: "-t {{dib_imagetype}}" + dib_imagetype_arg: "-t {{ dib_imagetype }}" when: dib_imagetype is defined - name: "Build image size (--image-size) option for disk-image-create" set_fact: - dib_imagesize_arg: "--image-size {{dib_imagesize}}" + dib_imagesize_arg: "--image-size {{ dib_imagesize }}" when: dib_imagesize is defined - name: "Build image cache (--image-cache) option for disk-image-create" set_fact: - dib_imagecache_arg: "--image-cache {{dib_imagecache}}" + dib_imagecache_arg: "--image-cache {{ dib_imagecache }}" when: dib_imagecache is defined - name: "Build max online resize (--max-online-resize) option for disk-image-create" set_fact: - dib_maxresize_arg: "--max-online-resize {{dib_maxresize}}" + dib_maxresize_arg: "--max-online-resize {{ dib_maxresize }}" when: dib_maxresize is defined - name: "Build minimum tmpfs size (--min-tmpfs) option for disk-image-create" set_fact: - dib_mintmpfs_arg: "--min-tmpfs {{dib_mintmpfs}}" + dib_mintmpfs_arg: "--min-tmpfs {{ dib_mintmpfs }}" when: dib_mintmpfs is defined - name: "Build mkfs options (--mkfs-options) option for disk-image-create" set_fact: - dib_mkfsfopts_arg: "-mkfs-options {{dib_mkfsopts}}" + dib_mkfsfopts_arg: "-mkfs-options {{ dib_mkfsopts }}" when: dib_mkfsopts is defined - name: "Build qemu image options (--qemu-img-options) option for disk-image-create" set_fact: - dib_qemuopts_arg: "--qemu-img-options {{dib_qemuopts}}" + dib_qemuopts_arg: "--qemu-img-options {{ dib_qemuopts }}" when: dib_qemuopts is defined - name: "Build root label (--root-label) option for disk-image-create" set_fact: - dib_rootlabel_arg: "--root-label {{dib_rootlabel}}" + dib_rootlabel_arg: "--root-label {{ dib_rootlabel }}" when: dib_rootlabel is defined - name: "Build ramdisk element (--ramdisk-element) option for disk-image-create" set_fact: - dib_rdelement_arg: "--ramdisk-element {{dib_rdelement}}" + dib_rdelement_arg: "--ramdisk-element {{ dib_rdelement }}" when: dib_rdelement is defined - name: "Build install type (--install-type) option for disk-image-create" set_fact: - dib_installtype_arg: "-t {{dib_installtype}}" + dib_installtype_arg: "-t {{ dib_installtype }}" when: dib_installtype is defined - name: "Build packages (-p) option for disk-image-create" set_fact: - dib_packages_arg: "-p {{dib_packages}}" + dib_packages_arg: "-p {{ dib_packages }}" when: dib_packages is defined and dib_packages != "" - name: "Set default of Debian Buster if building debian and not explicitly set, overwride with dib_os_release setting" set_fact: @@ -127,10 +127,10 @@ DIB_REPOREF_requirements: HEAD - name: "Initialize the DIB environment variables fact" set_fact: - dib_env_vars_final: "{{dib_env_vars | combine(dib_source_repositories)}}" + dib_env_vars_final: "{{ dib_env_vars | combine(dib_source_repositories) }}" - name: "Set the DIB_RELEASE environment variable if set" set_fact: - dib_env_vars_final: "{{dib_env_vars_final | combine({'DIB_RELEASE':dib_os_release}) }}" + dib_env_vars_final: "{{ dib_env_vars_final | combine({'DIB_RELEASE':dib_os_release}) }}" when: dib_os_release is defined - name: "Build ELEMENTS_PATH variable from IPA builder element folder" set_fact: @@ -160,27 +160,27 @@ - name: "Build argument list" set_fact: dib_arglist: > - {{dib_trace_arg|default('')}} - {{dib_uncompressed_arg|default('')}} - {{dib_clearenv_arg|default('')}} - {{dib_notmpfs_arg|default('')}} - {{dib_offline_arg|default('')}} - {{dib_skipbase_arg|default('')}} - {{dib_arch_arg|default('')}} - {{dib_imagename_arg|default('')}} - {{dib_imagetype_arg|default('')}} - {{dib_imagesize_arg|default('')}} - {{dib_imagecache_arg|default('')}} - {{dib_maxresize_arg|default('')}} - {{dib_mintmpfs_arg|default('')}} - {{dib_mkfsopts_arg|default('')}} - {{dib_qemuopts_arg|default('')}} - {{dib_rootlabel_arg|default('')}} - {{dib_rdelement_arg|default('')}} - {{dib_installtype_arg|default('')}} - {{dib_packages_arg|default('')}} - {{dib_os_element}} - {{dib_elements|default('')}} + {{ dib_trace_arg|default('') }} + {{ dib_uncompressed_arg|default('') }} + {{ dib_clearenv_arg|default('') }} + {{ dib_notmpfs_arg|default('') }} + {{ dib_offline_arg|default('') }} + {{ dib_skipbase_arg|default('') }} + {{ dib_arch_arg|default('') }} + {{ dib_imagename_arg|default('') }} + {{ dib_imagetype_arg|default('') }} + {{ dib_imagesize_arg|default('') }} + {{ dib_imagecache_arg|default('') }} + {{ dib_maxresize_arg|default('') }} + {{ dib_mintmpfs_arg|default('') }} + {{ dib_mkfsopts_arg|default('') }} + {{ dib_qemuopts_arg|default('') }} + {{ dib_rootlabel_arg|default('') }} + {{ dib_rdelement_arg|default('') }} + {{ dib_installtype_arg|default('') }} + {{ dib_packages_arg|default('') }} + {{ dib_os_element }} + {{ dib_elements|default('') }} - name: Install debootstrap if building a Debian image package: name: debootstrap @@ -191,7 +191,7 @@ and test_image_initramfs_present.stat.exists == false and ("debian" in dib_os_element or "ubuntu" in dib_os_element) - name: "Initiate image build" - command: disk-image-create {{dib_arglist}} + command: disk-image-create {{ dib_arglist }} environment: "{{ dib_env_vars_final | combine(bifrost_venv_env) }}" when: - not build_ramdisk | bool @@ -199,7 +199,7 @@ - not test_image_dib_present.stat.exists - not test_image_initramfs_present.stat.exists - name: "Initiate ramdisk build" - command: ramdisk-image-create {{dib_arglist}} + command: ramdisk-image-create {{ dib_arglist }} environment: "{{ dib_env_vars_final | combine(bifrost_venv_env) }}" when: - build_ramdisk | bool diff --git a/playbooks/roles/bifrost-create-vm-nodes/tasks/prepare_libvirt.yml b/playbooks/roles/bifrost-create-vm-nodes/tasks/prepare_libvirt.yml index 9864d68a3..3ff0fcaf2 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/tasks/prepare_libvirt.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/tasks/prepare_libvirt.yml @@ -33,7 +33,7 @@ log_outputs="1:file:/var/log/libvirt/libvirtd.log" - name: "Restart libvirt service" - service: name="{{libvirt_service_name}}" state=restarted + service: name="{{ libvirt_service_name }}" state=restarted # NOTE(Shrews) We need to enable ip forwarding for the libvirt bridge to # operate properly with dnsmasq. This should be done before starting dnsmasq. diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml index 53072832e..667288792 100644 --- a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml @@ -88,7 +88,7 @@ state: present config_drive: "{{ deploy_url_protocol }}://{{ internal_ip }}:{{ file_url_port }}/configdrive-{{ uuid }}.iso.gz" instance_info: - image_source: "{{ deploy_url_protocol }}://{{ internal_ip }}:{{ file_url_port }}/{{deploy_image_filename}}" + image_source: "{{ deploy_url_protocol }}://{{ internal_ip }}:{{ file_url_port }}/{{ deploy_image_filename }}" image_checksum: "{{ test_deploy_image.stat.checksum }}" image_disk_format: "qcow2" wait: "{{ wait_for_node_deploy }}" diff --git a/playbooks/roles/bifrost-ironic-install/tasks/create_tftpboot.yml b/playbooks/roles/bifrost-ironic-install/tasks/create_tftpboot.yml index 8a7f5273d..e395c8dba 100644 --- a/playbooks/roles/bifrost-ironic-install/tasks/create_tftpboot.yml +++ b/playbooks/roles/bifrost-ironic-install/tasks/create_tftpboot.yml @@ -16,7 +16,7 @@ # TODO(TheJulia): The pxelinux folder is statically coded in ironic. # For now, we need to use it, but we can patch that. - name: "Set up PXE and iPXE folders" - file: name={{item}} owner=ironic group=ironic state=directory mode=0755 + file: name={{ item }} owner=ironic group=ironic state=directory mode=0755 loop: - /tftpboot - /tftpboot/pxelinux.cfg @@ -121,7 +121,7 @@ # TODO(TheJulia): The pxelinux folder is statically coded in ironic. # For now, we need to use it, but we can patch that. -- name: "Inspector - Place default tftp boot file in {{ http_boot_folder}}/pxelinux.cfg/" +- name: "Inspector - Place default tftp boot file in {{ http_boot_folder }}/pxelinux.cfg/" template: src: inspector-default-boot-ipxe.j2 dest: "{{ http_boot_folder }}/pxelinux.cfg/default" diff --git a/playbooks/roles/bifrost-ironic-install/tasks/inspector_bootstrap.yml b/playbooks/roles/bifrost-ironic-install/tasks/inspector_bootstrap.yml index 3668a3363..caf7c3a8f 100644 --- a/playbooks/roles/bifrost-ironic-install/tasks/inspector_bootstrap.yml +++ b/playbooks/roles/bifrost-ironic-install/tasks/inspector_bootstrap.yml @@ -125,7 +125,7 @@ - name: "Inspector - Place service" template: src: systemd_template.j2 - dest: "{{ init_dest_dir }}{{item.service_name}}.service" + dest: "{{ init_dest_dir }}{{ item.service_name }}.service" owner: root group: root # FIXME(dtantsur): this is an awkward way to use loop... diff --git a/playbooks/roles/bifrost-keystone-client-config/tasks/main.yml b/playbooks/roles/bifrost-keystone-client-config/tasks/main.yml index 1e5632268..6a55e0172 100644 --- a/playbooks/roles/bifrost-keystone-client-config/tasks/main.yml +++ b/playbooks/roles/bifrost-keystone-client-config/tasks/main.yml @@ -19,7 +19,7 @@ config_password: "{{ config_password }}" config_project_name: "{{ config_project_name }}" config_region_name: "{{ config_region_name }}" - config_auth_url: "{{ config_auth_url}}" + config_auth_url: "{{ config_auth_url }}" config_project_domain_id: "{{ config_project_domain_id|default('default') }}" config_user_domain_id: "{{ config_user_domain_id|default('default') }}" when: diff --git a/playbooks/roles/bifrost-keystone-install/tasks/bootstrap.yml b/playbooks/roles/bifrost-keystone-install/tasks/bootstrap.yml index 01a5edb93..537ec633b 100644 --- a/playbooks/roles/bifrost-keystone-install/tasks/bootstrap.yml +++ b/playbooks/roles/bifrost-keystone-install/tasks/bootstrap.yml @@ -165,7 +165,7 @@ user: name: "keystone" append: yes - groups: "{{nginx_user}}" # TODO(TheJulia): Split webserver user/group. + groups: "{{ nginx_user }}" # TODO(TheJulia): Split webserver user/group. - name: "Make folder for keystone logs" file: @@ -184,7 +184,7 @@ file: path: /var/www/keystone/public owner: "keystone" - group: "{{nginx_user}}" + group: "{{ nginx_user }}" mode: 0754 # Note(ashestakov): "copy" module in ansible doesn't support recursive @@ -196,7 +196,7 @@ file: path: /var/www/keystone/admin owner: "keystone" - group: "{{nginx_user}}" + group: "{{ nginx_user }}" mode: 0754 - name: "Ensure /etc/uwsgi exists" diff --git a/playbooks/roles/bifrost-test-dhcp/tasks/main.yml b/playbooks/roles/bifrost-test-dhcp/tasks/main.yml index 764b59565..3814425e7 100644 --- a/playbooks/roles/bifrost-test-dhcp/tasks/main.yml +++ b/playbooks/roles/bifrost-test-dhcp/tasks/main.yml @@ -14,6 +14,6 @@ --- - name: Execute python dhcp check file become: true - script: test-dhcp.py "{{inventory_dhcp}}" "{{inventory_dhcp_static_ip}}" + script: test-dhcp.py "{{ inventory_dhcp }}" "{{ inventory_dhcp_static_ip }}" args: - executable: "{{ansible_python.executable}}" + executable: "{{ ansible_python.executable }}" diff --git a/playbooks/roles/ironic-enroll-dynamic/tasks/main.yml b/playbooks/roles/ironic-enroll-dynamic/tasks/main.yml index 527e11bb6..a04e3a0f1 100644 --- a/playbooks/roles/ironic-enroll-dynamic/tasks/main.yml +++ b/playbooks/roles/ironic-enroll-dynamic/tasks/main.yml @@ -29,7 +29,7 @@ uuid: "{{ uuid | default() }}" name: "{{ name | default() }}" state: present - nics: "{{nics}}" + nics: "{{ nics }}" properties: "{{ properties | default({}) }}" driver_info: power: "{{ driver_info.power }}" diff --git a/playbooks/test-bifrost.yaml b/playbooks/test-bifrost.yaml index 145cbbb47..a3fd1993f 100644 --- a/playbooks/test-bifrost.yaml +++ b/playbooks/test-bifrost.yaml @@ -62,7 +62,7 @@ # NOTE(TheJulia): This creates the guest image. - role: bifrost-create-dib-image dib_imagetype: "qcow2" - dib_imagename: "{{deploy_image}}" + dib_imagename: "{{ deploy_image }}" dib_os_element: "debian" dib_os_release: "buster" dib_elements: "vm enable-serial-console simple-init {{ extra_dib_elements|default('') }}" @@ -162,7 +162,7 @@ # serving these requests. - name: Power on remaining test VMs virt: - name: "{{item.key}}" + name: "{{ item.key }}" state: running with_dict: "{{ lookup('file', not_enrolled_data_file) | from_json }}" ignore_errors: yes