-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.yaml
87 lines (80 loc) · 2.87 KB
/
example.yaml
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
---
# requires the mini-lab to be running
- name: Running modules
hosts: localhost
connection: local
gather_facts: no
vars:
metal_stack_release_version: develop
metal_api_url: http://api.172.17.0.1.nip.io:8080/metal
metal_api_edit_key: metal-edit
setup_yaml:
- url: https://raw.githubusercontent.com/metal-stack/releases/{{ metal_stack_release_version }}/release.yaml
meta_var: metal_stack_release
roles:
- ansible-common
- metal-roles
- metal-roles/control-plane/roles/metal-python
tasks:
- name: Allocate network
metal_network:
api_url: "{{ metal_api_url }}"
api_hmac: "{{ metal_api_edit_key }}"
name: test
description: test network
partition: mini-lab
project: 00000000-0000-0000-0000-000000000000
register: network
- name: Lookup project network
set_fact:
project_networks: "{{ lookup('metal', 'search', 'network', api_hmac=metal_api_edit_key, projectid='00000000-0000-0000-0000-000000000000') }}"
- name: Assert network
assert:
fail_msg: "network was not created properly"
quiet: yes
that:
- project_networks | length == 1
- project_networks[0].name == "test"
- project_networks[0].description == "test network"
- project_networks[0].partitionid == "mini-lab"
- project_networks[0].parentnetworkid == "tenant-super-network-mini-lab"
- project_networks[0].projectid == "00000000-0000-0000-0000-000000000000"
- project_networks[0].nat == False
- project_networks[0].underlay == False
- project_networks[0].privatesuper == False
- project_networks[0].vrf > 0
- name: Allocate IP
metal_ip:
api_url: "{{ metal_api_url }}"
api_hmac: "{{ metal_api_edit_key }}"
network: "{{ network.id }}"
name: test
description: test ip
project: 00000000-0000-0000-0000-000000000000
register: ip
- name: Lookup IP
set_fact:
looked_up_ip: "{{ lookup('metal', 'get', 'ip', api_hmac=metal_api_edit_key, id=ip.ip) }}"
- name: Assert IP
assert:
fail_msg: "ip was not created properly"
quiet: yes
that:
- looked_up_ip.name == "test"
- looked_up_ip.description == "test ip"
- looked_up_ip.ipaddress == ip.ip
- looked_up_ip.networkid == network.id
- looked_up_ip.projectid == "00000000-0000-0000-0000-000000000000"
- looked_up_ip.type == "ephemeral"
- name: Release IP
metal_ip:
api_url: "{{ metal_api_url }}"
api_hmac: "{{ metal_api_edit_key }}"
ip: "{{ ip.ip }}"
state: absent
- name: Release network
metal_network:
api_url: "{{ metal_api_url }}"
api_hmac: "{{ metal_api_edit_key }}"
id: "{{ network.id }}"
state: absent