metalsmith/playbooks/integration/exercise.yaml

83 lines
2.2 KiB
YAML

- name: Create a port
command: openstack port create --network private test-port
when: precreate_port
- name: Set port argument
set_fact:
nic:
port: test-port
when: precreate_port
- name: Set network argument
set_fact:
nic:
network: private
when: not precreate_port
- name: Deploy a node
include_role:
name: metalsmith_deployment
vars:
metalsmith_resource_class: baremetal
metalsmith_instances:
- hostname: test
image: "{{ image }}"
netboot: "{{ netboot }}"
nics:
- "{{ nic }}"
root_size: 9
ssh_public_keys:
- "{{ ssh_key_file }}"
extra_args: -vv
- name: Get instance info via CLI
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: Show active node information
command: openstack baremetal node show {{ instance.node.uuid }}
- 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: precreate_port
# FIXME(dtantsur): fails because of ironic mis-behavior
ignore_errors: true