aboutsummaryrefslogtreecommitdiffstats
path: root/roles/vmm/tasks
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2020-11-10 20:46:04 +0100
committerbinary <me@rgoncalves.se>2020-11-10 20:46:04 +0100
commit0a673e300800b91342499cec9cd482b5d2d9c603 (patch)
tree752309b2f30928063340afefe39682679491a451 /roles/vmm/tasks
parent89c7516b1f9ec4ce7ce2947f98f2070c242f4459 (diff)
downloadinfrastructure-0a673e300800b91342499cec9cd482b5d2d9c603.tar.gz
Fully working init for alpine vm
Diffstat (limited to 'roles/vmm/tasks')
-rw-r--r--roles/vmm/tasks/init_vm_alpine.yml (renamed from roles/vmm/tasks/init_vm.yml)38
1 files changed, 25 insertions, 13 deletions
diff --git a/roles/vmm/tasks/init_vm.yml b/roles/vmm/tasks/init_vm_alpine.yml
index 6b5cf4d..0c66a44 100644
--- a/roles/vmm/tasks/init_vm.yml
+++ b/roles/vmm/tasks/init_vm_alpine.yml
@@ -1,23 +1,38 @@
-# vmm ~~ tasks/init_vm.yml
+# 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
-- set_fact:
- iso: "{{ vms | selectattr('name', 'equalto', guest) | map(attribute='iso') | first }}"
-
-- debug:
- var: iso
-
-- include: set_facts.yml
-
- name: Start temporary vm
shell: vmctl start -r {{ iso_latest }} -d {{ disk_file }} -n {{ vmm.switch.name }} -m 1G vm-tmp
@@ -26,13 +41,10 @@
seconds: 30
- name: Init vm via script
- script: init_vm_serial.py \
+ 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') }}"
- args:
- executable: "/usr/local/bin/python3"
-
remember that computers suck.