aboutsummaryrefslogtreecommitdiffstats
path: root/roles/bhyve/tasks/main.yml
blob: 3ff902a12e344e429afd063d0d62000b5b84f00a (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67

# bhyve ~~ roles/bhyve/tasks/main.yml
# bhyve hypervisor configuration

---

- name: create bhyve group
  group:
    name: bhyve
    state: present

- name: create bhyve user
  user:
    name: bhyve
    group: bhyve
    comment: Unpreviliged user for bhyve guests
    system: true

- name: check existence of bhyve directory
  file:
    path: /data/bhyve
    owner: bhyve
    group: bhyve
    state: directory
    mode: 0711

- name: load bhyve module
  shell: "! kldstat | grep vmm && kldload vmm"
  failed_when: false

- name: install bhyve components
  package: name="{{ item }}"
  loop:
    - vm-bhyve
    - bhyve-firmware
    - grub2-bhyve
    - devcpu-data

- name: enable bhyve vm
  shell: |
    sysrc vm_enable="YES"
    sysrc vm_dir="/data/bhyve"

- name: init vm directory and filesets
  shell: vm init

- name: create network switch
  shell: |
    vm switch create {{ hypervisor.switch }}
    vm switch add public {{ hypervisor.interface }}
  ignore_errors: true

- name: create per vm configuration
  include: guest.yml guest="{{ item }}"
  loop: "{{ vms }}"

- name: activate on boot all enabled vm
  lineinfile:
    path: /etc/rc.conf
    regexp: "^vm_list="
    line: vm_list="{% for vm in vms %}{{ vm.name }} {% endfor %}"

- name: set delay on boot between vm
  lineinfile:
    path: /etc/rc.conf
    regexp: "^vm_delay="
    line: vm_delay="5"
remember that computers suck.