aboutsummaryrefslogtreecommitdiffstats
path: root/roles/bhyve/tasks/main.yml
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2020-11-19 23:40:34 +0100
committerbinary <me@rgoncalves.se>2020-11-19 23:40:34 +0100
commit3e891b1a1fe21c26e7a09293106bf60dea6334e5 (patch)
treea29d9e192423a39f9e6720a6acdaa05a24b0676f /roles/bhyve/tasks/main.yml
parentc7cca6eb560146116a57fb2a2bfff35c9ba023bc (diff)
downloadinfrastructure-3e891b1a1fe21c26e7a09293106bf60dea6334e5.tar.gz
Basic behyve initialization
Diffstat (limited to 'roles/bhyve/tasks/main.yml')
-rw-r--r--roles/bhyve/tasks/main.yml67
1 files changed, 67 insertions, 0 deletions
diff --git a/roles/bhyve/tasks/main.yml b/roles/bhyve/tasks/main.yml
new file mode 100644
index 0000000..34cafd8
--- /dev/null
+++ b/roles/bhyve/tasks/main.yml
@@ -0,0 +1,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
+ shell: /sbin/nologin
+ 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
+
+- 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.