summaryrefslogtreecommitdiff
path: root/roles/vm/host/base
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-07-07 22:09:19 +0200
committerChristian Pointner <equinox@spreadspace.org>2020-07-11 02:29:02 +0200
commit6eacc2ad5539abf37dc90cd378b44320f7758869 (patch)
treeeacbf207b610a8ee93f830b381d91491671f6ae5 /roles/vm/host/base
parentch-oulu: interface config (diff)
refactor vm role names
Diffstat (limited to 'roles/vm/host/base')
-rw-r--r--roles/vm/host/base/handlers/main.yml5
-rw-r--r--roles/vm/host/base/tasks/main.yml49
-rw-r--r--roles/vm/host/base/tasks/zfs.yml20
3 files changed, 74 insertions, 0 deletions
diff --git a/roles/vm/host/base/handlers/main.yml b/roles/vm/host/base/handlers/main.yml
new file mode 100644
index 00000000..6541dd80
--- /dev/null
+++ b/roles/vm/host/base/handlers/main.yml
@@ -0,0 +1,5 @@
+---
+- name: restart haveged
+ service:
+ name: haveged
+ state: restarted
diff --git a/roles/vm/host/base/tasks/main.yml b/roles/vm/host/base/tasks/main.yml
new file mode 100644
index 00000000..1a7cb7d8
--- /dev/null
+++ b/roles/vm/host/base/tasks/main.yml
@@ -0,0 +1,49 @@
+---
+- name: install dependencies
+ apt:
+ name:
+ - qemu-kvm
+ - # configuration package, pulls in libvirt-clients and libvirt-daemon
+ libvirt-daemon-system
+ - python-libvirt
+ - haveged
+ - bridge-utils
+ - acl
+ state: present
+
+- name: configure haveged
+ lineinfile:
+ regexp: "^#?DAEMON_ARGS"
+ line: 'DAEMON_ARGS="-w 3072"'
+ path: /etc/default/haveged
+ notify: restart haveged
+
+- name: prepare zfs volumes
+ when: "'zfs' in vm_host"
+ include_tasks: zfs.yml
+
+- name: create lvm-based disk for installers
+ when: installer_lvm is defined
+ block:
+ - name: create logical volume
+ lvol:
+ vg: "{{ installer_lvm.vg }}"
+ lv: "{{ installer_lvm.lv }}"
+ size: "{{ installer_lvm.size }}"
+
+ - name: create filesystem
+ filesystem:
+ fstype: "{{ installer_lvm.fs }}"
+ dev: "/dev/mapper/{{ installer_lvm.vg | replace('-', '--') }}-{{ installer_lvm.lv | replace('-', '--') }}"
+
+ - name: mount filesytem
+ mount:
+ src: "/dev/mapper/{{ installer_lvm.vg | replace('-', '--') }}-{{ installer_lvm.lv | replace('-', '--') }}"
+ path: "{{ installer_base_path }}"
+ fstype: "{{ installer_lvm.fs }}"
+ state: mounted
+
+- name: make sure installer directory exists
+ file:
+ name: "{{ installer_base_path }}"
+ state: directory
diff --git a/roles/vm/host/base/tasks/zfs.yml b/roles/vm/host/base/tasks/zfs.yml
new file mode 100644
index 00000000..b84f2d0d
--- /dev/null
+++ b/roles/vm/host/base/tasks/zfs.yml
@@ -0,0 +1,20 @@
+---
+- name: create zfs base datasets
+ loop: "{{ lookup('dict', vm_host.zfs, wantlist=True) }}"
+ loop_control:
+ label: "{{ item.key }} -> {{ item.value.pool }}/{{ item.value.name }} ({{ (item.value.properties | default({})).items() | map('join', '=') | join(', ') }})"
+ vars:
+ default_properties:
+ canmount: no
+ mountpoint: none
+ zfs:
+ name: "{{ item.value.pool }}/{{ item.value.name }}"
+ state: present
+ extra_zfs_properties: "{{ default_properties | combine(item.value.properties | default({})) }}"
+
+- name: configure lvm to ignore zfs volumes
+ lineinfile:
+ path: /etc/lvm/lvm.conf
+ backrefs: yes
+ regexp: '^\s*#?\s*global_filter\s*='
+ line: ' global_filter = [ "r|/dev/zd[0-9]+|" ]'