summaryrefslogtreecommitdiff
path: root/roles/vm/guest/install/tasks/main.yml
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-11-21 03:42:54 +0100
committerChristian Pointner <equinox@spreadspace.org>2020-11-21 03:42:54 +0100
commit8828d4e11c28da88d65e45014431361aabb0c3d5 (patch)
tree759456a48196e108cf35bab4f1c6a774e8c20170 /roles/vm/guest/install/tasks/main.yml
parentadd some vmhost test machines (diff)
use delegation for vm/guest install and define
Diffstat (limited to 'roles/vm/guest/install/tasks/main.yml')
-rw-r--r--roles/vm/guest/install/tasks/main.yml97
1 files changed, 51 insertions, 46 deletions
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