/
test-ironic-cli.yml
128 lines (111 loc) · 3.68 KB
/
test-ironic-cli.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
# Copyright 2016, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Test the ironic CLI
hosts: hosts
user: root
become: true
gather_facts: false
tasks:
- name: Run the ironic chassis-list command
shell: >
. /root/openrc && ironic chassis-list
register: chassis_table
tags:
- skip_ansible_lint
- name: Check that the chassis-list command succeeded
assert:
that:
- "'Description' in chassis_table.stdout"
- name: Run the ironic node-list command
shell: >
. /root/openrc && ironic node-list
register: node_table
tags:
- skip_ansible_lint
- name: Check that the node-list command succeeded
assert:
that:
- "'UUID' in node_table.stdout"
- name: Run the ironic driver-list command
shell: >
. /root/openrc && ironic driver-list
register: driver_table
tags:
- skip_ansible_lint
- name: Check that the driver-list command succeeded
assert:
that:
- "'Supported' in driver_table.stdout"
- name: Create a node
shell: >
. /root/openrc && ironic node-create -d agent_ipmitool
-i ipmi_address=1.2.3.4
-i ipmi_password="TrickyPa55"
-i ipmi_username="admin"
-i deploy_ramdisk="http://example.com/ramdisk.qcow"
-i deploy_kernel="http://example.com/kernel.tgz"
-n happynode
register: node_created
tags:
- skip_ansible_lint
- name: Check that the node was created
assert:
that:
- "'happynode' in node_created.stdout"
- "'agent_ipmitool' in node_created.stdout"
- "'1.2.3.4' in node_created.stdout"
- "'admin' in node_created.stdout"
- "'http://example.com/ramdisk.qcow' in node_created.stdout"
- "'http://example.com/kernel.tgz' in node_created.stdout"
- name: Run the node-validate command
shell: >
. /root/openrc && ironic node-validate happynode
register: node_validated
tags:
- skip_ansible_lint
- name: Check that node-validate returned something sensible
assert:
that:
- "'Reason' in node_validated.stdout"
- name: Create a port
shell: >
. /root/openrc && ironic port-create -n $(ironic node-list | grep 'happynode' | cut -f 2 -d "|") -a de:ad:be:ef:de:ad
register: port_created
tags:
- skip_ansible_lint
- name: Check that the port was created
assert:
that:
- "'de:ad:be:ef:de:ad' in port_created.stdout"
- name: Update a node (in this case, change its name)
shell: >
. /root/openrc && ironic node-update happynode replace name=cheerynode
register: name_changed
tags:
- skip_ansible_lint
- name: Check that the name was changed
assert:
that:
- "'cheerynode' in name_changed.stdout"
- name: Remove a node
shell: >
. /root/openrc && ironic node-delete cheerynode
register: node_deleted
tags:
- skip_ansible_lint
- name: Check that a node was deleted
assert:
that:
- "'Deleted' in node_deleted.stdout"