summaryrefslogtreecommitdiff
path: root/roles/vm/guest/install/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/vm/guest/install/tasks')
-rw-r--r--roles/vm/guest/install/tasks/installer-debian.yml8
-rw-r--r--roles/vm/guest/install/tasks/installer-openbsd.yml8
-rw-r--r--roles/vm/guest/install/tasks/main.yml97
3 files changed, 61 insertions, 52 deletions
diff --git a/roles/vm/guest/install/tasks/installer-debian.yml b/roles/vm/guest/install/tasks/installer-debian.yml
index b0bc6e9e..9e484b88 100644
--- a/roles/vm/guest/install/tasks/installer-debian.yml
+++ b/roles/vm/guest/install/tasks/installer-debian.yml
@@ -1,17 +1,19 @@
---
+## this file is sourced using import_task and all task are therefore delegated to the vm-host
- name: fetch debian installer files
vars:
+ installer_base_path: "{{ hostvars[vm_host_cooked.name].installer_base_path }}"
debian_installer_distro: "{{ install_distro }}"
debian_installer_codename: "{{ install_codename }}"
- debian_installer_arch: "{{ hostvars[install_hostname].install_cooked.arch | default('amd64') }}"
+ debian_installer_arch: "{{ install_cooked.arch | default('amd64') }}"
debian_installer_variant: netboot
import_role:
name: installer/debian/fetch
- name: copy the installer files to the temporary installer directory
loop:
- - linux
- - initrd.gz
+ - linux
+ - initrd.gz
copy:
remote_src: yes
src: "{{ debian_installer_target_dir }}/{{ item }}"
diff --git a/roles/vm/guest/install/tasks/installer-openbsd.yml b/roles/vm/guest/install/tasks/installer-openbsd.yml
index cc59ee36..903e94e2 100644
--- a/roles/vm/guest/install/tasks/installer-openbsd.yml
+++ b/roles/vm/guest/install/tasks/installer-openbsd.yml
@@ -1,17 +1,19 @@
---
+## this file is sourced using import_task and all task are therefore delegated to the vm-host
- name: fetch openbsd installer files
vars:
+ installer_base_path: "{{ hostvars[vm_host_cooked.name].installer_base_path }}"
openbsd_installer_version: "{{ install_codename }}"
- openbsd_installer_arch: "{{ hostvars[install_hostname].install_cooked.arch | default('amd64') }}"
+ openbsd_installer_arch: "{{ install_cooked.arch | default('amd64') }}"
import_role:
name: installer/openbsd/fetch
- name: generate host specific autoinstall iso
vars:
- obsd_autoinstall_orig_iso: "{{ installer_base_path }}/openbsd-{{ install_codename }}/{{ hostvars[install_hostname].install_cooked.arch | default('amd64') }}/install{{ openbsd_installer_version_short }}.iso"
+ obsd_autoinstall_orig_iso: "{{ hostvars[vm_host_cooked.name].installer_base_path }}/openbsd-{{ install_codename }}/{{ install_cooked.arch | default('amd64') }}/install{{ openbsd_installer_version_short }}.iso"
obsd_autoinstall_tmpdir: "{{ tmpdir.path }}"
obsd_autoinstall_version: "{{ install_codename }}"
- obsd_autoinstall_arch: "{{ hostvars[install_hostname].install_cooked.arch | default('amd64') }}"
+ obsd_autoinstall_arch: "{{ install_cooked.arch | default('amd64') }}"
obsd_autoinstall_serial_device: com0
install_interface: vio0
import_role:
diff --git a/roles/vm/guest/install/tasks/main.yml b/roles/vm/guest/install/tasks/main.yml
index cf1286c5..0172c5bb 100644
--- a/roles/vm/guest/install/tasks/main.yml
+++ b/roles/vm/guest/install/tasks/main.yml
@@ -1,8 +1,9 @@
---
- name: create lvm-based disks for vm
- loop: "{{ hostvars[install_hostname].install_cooked.disks.virtio | default({}) | combine(hostvars[install_hostname].install_cooked.disks.scsi | default({})) | dict2items | selectattr('value.type', 'eq', 'lvm') | list }}"
+ loop: "{{ install_cooked.disks.virtio | default({}) | combine(install_cooked.disks.scsi | default({})) | dict2items | selectattr('value.type', 'eq', 'lvm') | list }}"
loop_control:
label: "{{ item.value.vg }} / {{ item.value.lv }} ({{ item.value.size }})"
+ delegate_to: "{{ vm_host_cooked.name }}"
lvol:
vg: "{{ item.value.vg }}"
lv: "{{ item.value.lv }}"
@@ -10,7 +11,8 @@
state: present
- name: create zfs base datasets for vm
- loop: "{{ hostvars[install_hostname].install_cooked.disks.virtio | default({}) | combine(hostvars[install_hostname].install_cooked.disks.scsi | default({})) | dict2items | selectattr('value.type', 'eq', 'zfs') | map(attribute='value.backend') | map('default', 'default') | unique | list }}"
+ loop: "{{ install_cooked.disks.virtio | default({}) | combine(install_cooked.disks.scsi | default({})) | dict2items | selectattr('value.type', 'eq', 'zfs') | map(attribute='value.backend') | map('default', 'default') | unique | list }}"
+ delegate_to: "{{ vm_host_cooked.name }}"
zfs:
name: "{{ vm_host_cooked.zfs[item].pool }}/{{ vm_host_cooked.zfs[item].name }}/{{ install_hostname }}"
state: present
@@ -19,72 +21,75 @@
mountpoint: none
- name: create zfs-based disk volumes for vm
- loop: "{{ hostvars[install_hostname].install_cooked.disks.virtio | default({}) | combine(hostvars[install_hostname].install_cooked.disks.scsi | default({})) | dict2items | selectattr('value.type', 'eq', 'zfs') | list }}"
+ loop: "{{ install_cooked.disks.virtio | default({}) | combine(install_cooked.disks.scsi | default({})) | dict2items | selectattr('value.type', 'eq', 'zfs') | list }}"
loop_control:
label: "{{ item.value.name }} on backend {{ item.value.backend | default('default') }} ({{ item.value.size }})"
+ delegate_to: "{{ vm_host_cooked.name }}"
zfs:
name: "{{ vm_host_cooked.zfs[item.value.backend | default('default')].pool }}/{{ vm_host_cooked.zfs[item.value.backend | default('default')].name }}/{{ install_hostname }}/{{ item.value.name }}"
state: present
extra_zfs_properties: "{{ item.value.properties | default({}) | combine({'volsize': item.value.size}) }}"
-- block:
- - name: create a temporary workdir
- tempfile:
- path: "{{ installer_base_path }}/"
- prefix: ".{{ install_hostname }}."
- state: directory
- register: tmpdir
+- delegate_to: "{{ vm_host_cooked.name }}"
+ block:
+ - name: create a temporary workdir
+ tempfile:
+ path: "{{ hostvars[vm_host_cooked.name].installer_base_path }}/"
+ prefix: ".{{ install_hostname }}."
+ state: directory
+ register: tmpdir
- - when: install_distro in ['debian', 'ubuntu']
- import_tasks: installer-debian.yml
+ - when: install_distro in ['debian', 'ubuntu']
+ import_tasks: installer-debian.yml
- - when: install_distro in ['openbsd']
- import_tasks: installer-openbsd.yml
+ - when: install_distro in ['openbsd']
+ import_tasks: installer-openbsd.yml
- - name: Make installer workdir readable by qemu
- acl:
- path: "{{ tmpdir.path }}"
- state: present
- entity: libvirt-qemu
- etype: user
- permissions: rx
+ - name: Make installer workdir readable by qemu
+ acl:
+ path: "{{ tmpdir.path }}"
+ state: present
+ entity: libvirt-qemu
+ etype: user
+ permissions: rx
- - name: define installer vm
- vars:
- vm_define_installer: yes
- installer_tmpdir: "{{ tmpdir.path }}"
- import_role:
- name: vm/guest/define
+ - name: define installer vm
+ vars:
+ vm_define_installer: yes
+ installer_tmpdir: "{{ tmpdir.path }}"
+ import_role:
+ name: vm/guest/define
- - debug:
- msg: "you can check on the status of the installer running this command 'virsh console {{ install_hostname }}' on host {{ inventory_hostname }}."
+ - debug:
+ msg: "you can check on the status of the installer running this command 'virsh console {{ install_hostname }}' on host {{ vm_host_cooked.name }}."
- - when: installer_manual_steps_msg is defined
- pause:
- prompt: |
- Mind that this installer needs manual steps to be performed:
+ - when: installer_manual_steps_msg is defined
+ pause:
+ prompt: |
+ Mind that this installer needs manual steps to be performed:
- {{ installer_manual_steps_msg | indent(2) }}
+ {{ installer_manual_steps_msg | indent(2) }}
- When done press ENTER to continue or CTRL-C then A to abort.
+ When done press ENTER to continue or CTRL-C then A to abort.
- - name: wait for installer to finish or crash
- wait_for_virt:
- name: "{{ install_hostname }}"
- states: shutdown,crashed
- timeout: 1800
- register: installer_result
- failed_when: installer_result.failed or installer_result.state == "crashed"
+ - name: wait for installer to finish or crash
+ wait_for_virt:
+ name: "{{ install_hostname }}"
+ states: shutdown,crashed
+ timeout: 1800
+ register: installer_result
+ failed_when: installer_result.failed or installer_result.state == "crashed"
always:
- - name: cleanup temporary workdir
- file:
- path: "{{ tmpdir.path }}"
- state: absent
+ - name: cleanup temporary workdir
+ file:
+ path: "{{ tmpdir.path }}"
+ state: absent
- name: define vm
vars:
vm_define_installer: no
+ delegate_to: "{{ vm_host_cooked.name }}"
import_role:
name: vm/guest/define