Files
metalsmith/playbooks/integration/exercise.yaml
Steve Baker a7bd8fe1ae metalsmith_deployment role switch to metalsmith_instances
Instead of wrapping the metalsmith CLI, the metalsmith_deployment role
now uses the metalsmith_instances module. There are differences between
the instances formats of the role and the module which are partially
resolved with a simple transformation module called
metalsmith_deployment_defaults.

A 'candidates' attribute is added to metalsmith_instances, but keeping
the single 'name' attribute to remain compatible with the TripleO
usage.

Unresolved differences between the 2 are described below:

metalsmith_instances doesn't have a per-instance state attribute,
instead it has one state attribute for all instances. I propose that
support for per-instance state is dropped. This was never documented
in the README.rst anyway.

extra_args only applies to a CLI. Apart from --dry-run these arguments
are either for output formatting or Ironic API authentication. I propose
that this option is dropped. A metalsmith_debug arg is added to make
the ouput more verbose.

Change-Id: Ia30620821182c58050813e807cdde50a27d03c15
2020-10-08 09:48:20 +13:00

106 lines
3.1 KiB
YAML

---
- 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_debug: true
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.id }}
- 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.id }} -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.id }} -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