--- - name: Create a port command: openstack port create --network private test-port when: metalsmith_precreate_port - name: Set port argument set_fact: nic: port: test-port when: metalsmith_precreate_port - name: Set network argument set_fact: nic: network: private when: not metalsmith_precreate_port - name: Deploy a node include_role: name: metalsmith_deployment vars: metalsmith_extra_args: -vv metalsmith_resource_class: baremetal metalsmith_instances: - hostname: test nics: - "{{ nic }}" ssh_public_keys: - "{{ ssh_key_file }}" user_name: "{{ configure_instance_user | default('') }}" - name: Get instance info via CLI show command: metalsmith --format=json show test register: instance_info - name: Register instance information set_fact: instance: "{{ (instance_info.stdout | from_json).test }}" failed_when: instance.state != 'active' or instance.node.provision_state != 'active' - name: Get instance info via CLI list command: metalsmith --format=json list register: instance_info_via_list - name: Verify that instance info via list is also correct set_fact: instance_via_list: "{{ (instance_info_via_list.stdout | from_json).test }}" failed_when: instance_via_list.state != 'active' or instance_via_list.node.provision_state != 'active' - name: Show active node information command: openstack baremetal node show {{ instance.node.uuid }} - name: Get IP address set_fact: instance_ip: "{{ instance.ip_addresses.values() | list | first | first }}" failed_when: not instance_ip - name: SSH into the instance command: > ssh -v -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=10 {{ configure_instance_user | default('cirros') }}@{{ instance_ip }} "cat /etc/hostname" register: ssh_result until: ssh_result is success retries: 30 delay: 20 - name: Undeploy a node command: metalsmith --debug undeploy --wait 900 test - name: Get the current status of the deployed node command: openstack baremetal node show {{ instance.node.uuid }} -f json register: undeployed_node_result - name: Parse node state set_fact: undeployed_node: "{{ undeployed_node_result.stdout | from_json }}" - name: Check that the node was undeployed fail: msg: The node is in unexpected status {{ undeployed_node }} when: undeployed_node.provision_state != "available" - name: Check that the node extra was cleared fail: msg: The node still has extra {{ undeployed_node }} when: undeployed_node.extra != {} - name: Get attached VIFs for the node command: openstack baremetal node vif list {{ instance.node.uuid }} -f value -c ID register: vif_list_output - name: Check that no VIFs are still attached fail: msg: Some VIFs are still attached when: vif_list_output.stdout != "" - name: Show remaining ports command: openstack port list - name: Delete created port command: openstack port delete test-port when: metalsmith_precreate_port # FIXME(dtantsur): fails because of ironic mis-behavior ignore_errors: true