From a756129b474be3cebad4eaca7b5f213b47045e76 Mon Sep 17 00:00:00 2001 From: Riccardo Pittau Date: Thu, 9 Nov 2023 11:16:49 +0100 Subject: [PATCH] Fix key-order ansible errors Also fix some spacing warnings Change-Id: Iec191273591ee88710438f3bbbf63ec242d0c247 --- .ansible-lint | 1 - playbooks/cleanup-deployment-images.yaml | 4 +-- playbooks/deploy-dynamic.yaml | 8 ++--- playbooks/enroll-dynamic.yaml | 8 ++--- .../example-deploy-all-available-nodes.yaml | 8 ++--- playbooks/install.yaml | 4 +-- playbooks/redeploy-dynamic.yaml | 22 ++++++------- .../tasks/create_vm.yml | 4 +-- .../bifrost-create-vm-nodes/tasks/main.yml | 4 +-- playbooks/test-bifrost-create-vm.yaml | 4 +-- playbooks/test-bifrost.yaml | 32 +++++++++---------- 11 files changed, 49 insertions(+), 50 deletions(-) diff --git a/.ansible-lint b/.ansible-lint index 5e4b5fa57..558feb1eb 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -4,7 +4,6 @@ skip_list: - fqcn[action-core] # Use FQCN for builtin actions - ignore-errors # Use failed_when and specify error conditions instead of using ignore_errors - jinja[invalid] # Unrecognized type - - key-order[play] # You can improve the play key order to: name, hosts, connection, become, gather_facts, vars, roles, environment - meta-no-info # meta/main.yml should contain relevant info - meta-no-tags # Tags must contain lowercase letters and digits only - name[casing] #All names should start with an uppercase letter diff --git a/playbooks/cleanup-deployment-images.yaml b/playbooks/cleanup-deployment-images.yaml index fb3650783..5822759eb 100644 --- a/playbooks/cleanup-deployment-images.yaml +++ b/playbooks/cleanup-deployment-images.yaml @@ -1,7 +1,7 @@ --- -- hosts: localhost +- name: "Remove the master_images folder and deployment kernel/ramdisk for clean redeployments when testing." + hosts: localhost connection: local - name: "Remove the master_images folder and deployment kernel/ramdisk for clean redeployments when testing." become: yes gather_facts: yes tasks: diff --git a/playbooks/deploy-dynamic.yaml b/playbooks/deploy-dynamic.yaml index e58fc2ab4..0364a7221 100644 --- a/playbooks/deploy-dynamic.yaml +++ b/playbooks/deploy-dynamic.yaml @@ -1,11 +1,11 @@ --- -- hosts: localhost - name: "Gather facts on localhost" +- name: "Gather facts on localhost" + hosts: localhost become: no gather_facts: yes -- hosts: baremetal - name: "Create configuration drive files and deploy machines from inventory" +- name: "Create configuration drive files and deploy machines from inventory" + hosts: baremetal become: no gather_facts: no roles: diff --git a/playbooks/enroll-dynamic.yaml b/playbooks/enroll-dynamic.yaml index a970695b1..ae7a820f0 100644 --- a/playbooks/enroll-dynamic.yaml +++ b/playbooks/enroll-dynamic.yaml @@ -1,11 +1,11 @@ --- -- hosts: localhost - name: "Gather facts on localhost" +- name: "Gather facts on localhost" + hosts: localhost become: no gather_facts: yes -- hosts: baremetal - name: "Enroll hardware from inventory into Ironic" +- name: "Enroll hardware from inventory into Ironic" + hosts: baremetal become: no gather_facts: no roles: diff --git a/playbooks/example-deploy-all-available-nodes.yaml b/playbooks/example-deploy-all-available-nodes.yaml index 36d8c6325..c47f7495a 100644 --- a/playbooks/example-deploy-all-available-nodes.yaml +++ b/playbooks/example-deploy-all-available-nodes.yaml @@ -16,13 +16,13 @@ # and the example role conditionals below to query current status and # deploy to nodes. --- -- hosts: localhost +- name: "Collect facts" + hosts: localhost connection: local - name: "Collect facts" become: no gather_facts: yes -- hosts: baremetal - name: "Create configuration drive files and deploy machines from inventory" +- name: "Create configuration drive files and deploy machines from inventory" + hosts: baremetal become: no connection: local roles: diff --git a/playbooks/install.yaml b/playbooks/install.yaml index ff6ebc48e..a8119bd90 100644 --- a/playbooks/install.yaml +++ b/playbooks/install.yaml @@ -1,6 +1,6 @@ --- -- hosts: target - name: "Install Ironic on the target host." +- name: "Install Ironic on the target host." + hosts: target become: yes gather_facts: yes vars: diff --git a/playbooks/redeploy-dynamic.yaml b/playbooks/redeploy-dynamic.yaml index 12e2458d4..d2e0e84af 100644 --- a/playbooks/redeploy-dynamic.yaml +++ b/playbooks/redeploy-dynamic.yaml @@ -19,23 +19,23 @@ # other operating systems or if your target node has multiple ethernet # interfaces. --- -- hosts: localhost +- name: "Collect facts" + hosts: localhost connection: local - name: "Collect facts" become: no gather_facts: yes -- hosts: baremetal - name: "Pull cloud configuration" - become: no +- name: "Pull cloud configuration" + hosts: baremetal connection: local + become: no roles: - role: bifrost-cloud-config -- hosts: baremetal - name: "Unprovision the nodes" - become: no +- name: "Unprovision the nodes" + hosts: baremetal connection: local + become: no pre_tasks: - name: "Pull initial ironic facts" openstack.cloud.baremetal_node_info: @@ -70,10 +70,10 @@ retries: "{{ available_state_wait_retries | default(45) }}" delay: "{{ provision_state_retry_interval | default(20) }}" -- hosts: baremetal - name: "Activate the nodes" - become: no +- name: "Activate the nodes" + hosts: baremetal connection: local + become: no roles: - role: bifrost-configdrives-dynamic when: diff --git a/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml b/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml index 55759dddf..fa4ce9a9e 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml @@ -51,7 +51,7 @@ virsh --connect {{ test_vm_libvirt_uri }} vol-create-as {{ test_vm_storage_pool }} {{ vm_name }}.qcow2 {{ test_vm_disk_gib | int + 1 }}G - --format qcow2 {{ prealloc|default("") }} + --format qcow2 {{ prealloc | default("") }} when: (vm_name + '.qcow2') not in ansible_libvirt_pools[test_vm_storage_pool].volumes - name: set path to the volume created @@ -108,7 +108,7 @@ when: vbmc_list.stdout.find(vm_name) != -1 - set_fact: - virtual_ipmi_port: "{{ (test_vm_ipmi_port_start|default(623) | int ) + (testvm_json_data | length) }}" + virtual_ipmi_port: "{{ (test_vm_ipmi_port_start | default(623) | int) + (testvm_json_data | length) }}" - name: plug vm into vbmc command: vbmc add {{ vm_name }} --libvirt-uri {{ test_vm_libvirt_uri }} --port {{ virtual_ipmi_port }} diff --git a/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml b/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml index d1ef98e59..10f899fc5 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml @@ -96,11 +96,11 @@ - name: truncate explicit list of vm names set_fact: - test_vm_node_names: "{{ test_vm_node_names[:(test_vm_num_nodes|int)] }}" + test_vm_node_names: "{{ test_vm_node_names[: (test_vm_num_nodes | int)] }}" - name: generate test vm names set_fact: - generated_test_vm_node_names: "{{ generated_test_vm_node_names|default([]) + [item] }}" + generated_test_vm_node_names: "{{ generated_test_vm_node_names | default([]) + [item] }}" with_sequence: count={{ test_vm_num_nodes | int }} format={{ test_vm_node_name_base }}%i when: test_vm_node_names | length == 0 diff --git a/playbooks/test-bifrost-create-vm.yaml b/playbooks/test-bifrost-create-vm.yaml index f525fadda..e24fcc141 100644 --- a/playbooks/test-bifrost-create-vm.yaml +++ b/playbooks/test-bifrost-create-vm.yaml @@ -1,8 +1,8 @@ # Create a default VM --- -- hosts: localhost +- name: "Executes install, enrollment, and testing in one playbook" + hosts: localhost connection: local - name: "Executes install, enrollment, and testing in one playbook" become: yes gather_facts: yes pre_tasks: diff --git a/playbooks/test-bifrost.yaml b/playbooks/test-bifrost.yaml index 643a74be5..6ff0c916d 100644 --- a/playbooks/test-bifrost.yaml +++ b/playbooks/test-bifrost.yaml @@ -6,9 +6,9 @@ # Execute the installation and VM startup test. # ansible-playbook -vvvv -i inventory/bifrost_inventory.py test-bifrost.yaml -e download_custom_deploy_image=true -e testing_user=cirros --- -- hosts: localhost +- name: "Prepare testing environment" + hosts: localhost connection: local - name: "Prepare testing environment" become: no gather_facts: yes tasks: @@ -35,28 +35,28 @@ - import_playbook: enroll-dynamic.yaml -- hosts: baremetal - name: "Test introspection data" - become: no +- name: "Test introspection data" + hosts: baremetal connection: local + become: no roles: - role: bifrost-test-inspection when: inspect_nodes | default(false) | bool - import_playbook: deploy-dynamic.yaml -- hosts: baremetal - name: "Prepare for deployment verification" - become: no +- name: "Prepare for deployment verification" + hosts: baremetal connection: local + become: no serial: 1 roles: - role: bifrost-prepare-for-test-dynamic # The testvm Host group is added by bifrost-prepare-for-test based # on the contents of the JSON file. -- hosts: test - name: "Tests connectivity to the VM" +- name: "Tests connectivity to the VM" + hosts: test become: no gather_facts: no remote_user: "{{ testing_user }}" @@ -69,9 +69,9 @@ - import_playbook: redeploy-dynamic.yaml when: redeploy_nodes | default(false) | bool -- hosts: baremetal +- name: "Unprovisions the test node" + hosts: baremetal connection: local - name: "Unprovisions the test node" become: no gather_facts: no roles: @@ -80,9 +80,9 @@ - role: ironic-delete-dynamic # The following tasks are intended to test DHCP functionality -- hosts: localhost +- name: "Start VMs that were not enrolled to ironic" + hosts: localhost connection: local - name: "Start VMs that were not enrolled to ironic" become: yes vars: not_enrolled_data_file: /tmp/baremetal.json.rest @@ -103,9 +103,9 @@ seconds: 30 when: inventory_dhcp | bool -- hosts: localhost +- name: "Executes DHCP test script" + hosts: localhost connection: local - name: "Executes DHCP test script" become: yes gather_facts: yes vars: