-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_compute_image.yml
60 lines (51 loc) · 1.81 KB
/
create_compute_image.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
---
- hosts: localhost
gather_facts: false
vars_files:
- vars/main.yml
tasks:
- name: Get compute imaging instance information
openstack.cloud.server_info:
server: "{{ cluster_name }}-compute-imaging"
register: server_info
- name: Detach floating IP from compute imaging instance
openstack.cloud.floating_ip:
state: absent
floating_ip_address: "{{ server_info.openstack_servers[0].public_v4 }}"
network: "{{ cluster_network_floating_ip_pool }}"
server: "{{ cluster_name }}-compute-imaging"
when: server_info.openstack_servers[0] is defined
- name: Shut down compute imaging instance
openstack.cloud.server_action:
server: "{{ cluster_name }}-compute-imaging"
action: stop
when: server_info.openstack_servers[0] is defined
- name: Delete compute imaging instance
openstack.cloud.server:
name: "{{ cluster_name }}-compute-imaging"
state: absent
- name: Wait for the compute image volume is detached
openstack.cloud.volume_info:
name: "{{ compute_node_image }}"
details: true
register: volumes_info
until: volumes_info.volumes[0].status is match("available")
- name: Delete compute image
openstack.cloud.image:
name: "{{ compute_node_image }}"
state: absent
- name: Create compute image
openstack.cloud.image:
name: "{{ compute_node_image }}"
volume: "{{ volumes_info.volumes[0].id }}"
#visibility: private
is_public: false
disk_format: raw
timeout: 1200
state: present
- name: Delete compute image volume
openstack.cloud.volume:
name: "{{ volumes_info.volumes[0].id }}"
state: absent
- debug:
msg: "Created {{ compute_node_image }}."