Skip to content

Commit eeca326

Browse files
committed
Add example for ISO eject
Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si>
1 parent 1e26405 commit eeca326

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

examples/iso_eject.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
- name: Eject ISO image from VM
3+
hosts: localhost
4+
connection: local
5+
gather_facts: false
6+
vars:
7+
vm_name: demo-vm
8+
iso_url: http://tinycorelinux.net/13.x/x86/release/TinyCore-current.iso
9+
iso_filename: "{{ iso_url | split('/') | last }}"
10+
11+
tasks:
12+
# ------------------------------------------------------
13+
- name: Prepare ISO
14+
block:
15+
- name: Download ISO from URL - {{ iso_filename }}
16+
ansible.builtin.get_url:
17+
url: "{{ iso_url }}"
18+
dest: /tmp/{{ iso_filename }}
19+
mode: "0644"
20+
21+
- name: Upload ISO to HyperCore - {{ iso_filename }}
22+
scale_computing.hypercore.iso:
23+
name: "{{ iso_filename }}"
24+
source: /tmp/{{ iso_filename }}
25+
state: present
26+
27+
# ------------------------------------------------------
28+
- name: Create VM {{ vm_name }}
29+
scale_computing.hypercore.vm:
30+
vm_name: "{{ vm_name }}"
31+
memory: "{{ '1 GB' | human_to_bytes }}"
32+
vcpu: 2
33+
disks:
34+
# - type: virtio_disk
35+
# disk_slot: 0
36+
# size: "{{ '10 GB' | human_to_bytes }}"
37+
- type: ide_cdrom
38+
disk_slot: 0
39+
iso_name: "{{ iso_filename }}"
40+
nics: []
41+
state: present
42+
power_state: shutdown
43+
operating_system: os_other
44+
45+
- &vm_info
46+
name: VM info
47+
block:
48+
- name: Get VM state
49+
scale_computing.hypercore.vm_info:
50+
vm_name: "{{ vm_name }}"
51+
register: vm_info
52+
53+
- name: Show VM disks
54+
ansible.builtin.debug:
55+
var: vm_info.records.0.disks
56+
57+
- name: Detach ISO from VM, leave empty CD-ROM, {{ vm_name }}
58+
scale_computing.hypercore.vm_disk:
59+
vm_name: "{{ vm_name }}"
60+
items:
61+
- disk_slot: 0
62+
type: ide_cdrom
63+
iso_name: ""
64+
state: present
65+
66+
- *vm_info

0 commit comments

Comments
 (0)