summaryrefslogtreecommitdiff
path: root/roles/vm/host/tasks/main.yml
blob: 390016a2fc346c22ce1b78d406032eaadbb2ee1d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
- 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: install vm-host network
  when: "'network' in vm_host"
  include_tasks: network.yml

- 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_path }}"
      fstype: "{{ installer_lvm.fs }}"
      state: mounted

- name: make sure installer directory exists
  file:
    name: "{{ installer_path }}"
    state: directory