blob: 0c66a441748ebc629be071fee36da646e0a48302 (
plain) (
blame)
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
|
# vmm ~~ tasks/init_vm_alpine.yml
---
- set_fact:
iso: "{{ vms | selectattr('name', 'equalto', guest) | map(attribute='iso') | first }}"
- include: set_facts.yml
- name: Check for existing drive
stat:
path: "{{ disk_file }}"
register: st_disk
- fail:
msg: "No empty disk detected ! You need to generated disks via hypervisor playbook"
when: not st_disk.stat.exists
- fail:
msg: "Existing installation detected ! Manual action on host required"
when: st_disk.stat.size > 500000
- include_role:
name: serial
- name: Copy vm init script
copy:
src: init_vm_alpine.py
dest: /data/python/init_vm_alpine.py
- name: Stop vm if running
shell: vmctl stop "{{ guest }}" ; vmctl stop vm-tmp
ignore_errors: true
- name: Start temporary vm
shell: vmctl start -r {{ iso_latest }} -d {{ disk_file }} -n {{ vmm.switch.name }} -m 1G vm-tmp
- name: Pause 30 seconds for vm boot
pause:
seconds: 30
- name: Init vm via script
command: python3 /data/python/init_vm_alpine.py \
{{ guest }} \
{{ hostvars[guest].ip.out }} \
{{ hypervisor.gateway }} \
{{ hypervisor.mask }} \
{{ _i.dns[0] }} \
"{{ lookup('file', inventory_dir + '/files/pubkeys/rgoncalves.pub') }}"
|