aboutsummaryrefslogblamecommitdiffstats
path: root/roles/vmm/tasks/init_vm.yml
blob: 6b5cf4d85954926b5969e5d7a9d968a6004b6227 (plain) (tree)
1
2
3
4
5
6
7
8







                          



                                                     
           












                                                                                                 










                                                                           
 

# vmm ~~ tasks/init_vm.yml

---

- include_role:
    name: serial

- 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

- name: Pause 30 seconds for vm boot
  pause:
    seconds: 30

- name: Init vm via script
  script: init_vm_serial.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.