2020-09-14 03:52:49 +02:00
|
|
|
|
---
|
|
|
|
|
- name: Define bhyve guest service definitions
|
|
|
|
|
file:
|
2022-07-04 02:58:24 +02:00
|
|
|
|
path: '{{ s6_etc_dir }}/service/bhyve-{{ item.0.name }}{{ item.1 }}'
|
2020-09-14 03:52:49 +02:00
|
|
|
|
state: directory
|
|
|
|
|
owner: root
|
|
|
|
|
group: wheel
|
|
|
|
|
mode: 0755
|
|
|
|
|
loop_control:
|
|
|
|
|
label: 'bhyve-{{ item.0.name }}{{ item.1 }}'
|
|
|
|
|
with_nested:
|
|
|
|
|
- '{{ bhyve_guests }}'
|
|
|
|
|
- '{{ bhyve_dirs }}'
|
|
|
|
|
notify:
|
|
|
|
|
- Reload s6-rc
|
|
|
|
|
|
|
|
|
|
- name: Instantiating service templates
|
|
|
|
|
template:
|
2022-07-04 02:58:24 +02:00
|
|
|
|
dest: '{{ s6_etc_dir }}/service/bhyve-{{ item.0.name }}{{ item.1.name }}'
|
2020-09-14 03:52:49 +02:00
|
|
|
|
src: 'bhyve{{ item.1.name }}.j2'
|
|
|
|
|
owner: root
|
|
|
|
|
group: wheel
|
|
|
|
|
mode: '{{ item.1.mode }}'
|
|
|
|
|
loop_control:
|
|
|
|
|
label: 'bhyve-{{ item.0.name }}{{ item.1.name }}'
|
|
|
|
|
with_nested:
|
|
|
|
|
- '{{ bhyve_guests }}'
|
|
|
|
|
- '{{ bhyve_templates }}'
|
|
|
|
|
notify:
|
|
|
|
|
- Reload s6-rc
|
|
|
|
|
|
|
|
|
|
- name: Flush handlers
|
|
|
|
|
meta: flush_handlers
|
|
|
|
|
|
|
|
|
|
- name: Start enabled bhyve guests
|
|
|
|
|
command: >
|
2022-07-04 02:58:24 +02:00
|
|
|
|
fdmove -c 2 1 s6-rc -l {{ s6_live_dir }} -v 2 -u change bhyve-{{ item.name }}
|
2020-09-14 03:52:49 +02:00
|
|
|
|
register: change
|
|
|
|
|
when: item.enabled | default
|
|
|
|
|
changed_when: change.stdout | length > 0
|
|
|
|
|
loop_control:
|
|
|
|
|
label: 'bhyve-{{ item.name }}'
|
|
|
|
|
with_items: '{{ bhyve_guests }}'
|
|
|
|
|
|
|
|
|
|
- name: Create bhyve service
|
|
|
|
|
file:
|
|
|
|
|
path: '{{ item }}'
|
|
|
|
|
state: directory
|
|
|
|
|
owner: root
|
|
|
|
|
group: wheel
|
|
|
|
|
mode: 0755
|
|
|
|
|
notify:
|
|
|
|
|
- Reload s6-rc
|
|
|
|
|
with_items:
|
2022-07-04 02:58:24 +02:00
|
|
|
|
- '{{ s6_etc_dir }}/service/bhyve'
|
|
|
|
|
- '{{ s6_etc_dir }}/service/bhyve-disabled'
|
|
|
|
|
- '{{ s6_etc_dir }}/service/bhyve-enabled'
|
2020-09-14 03:52:49 +02:00
|
|
|
|
|
|
|
|
|
- name: Declare bhyve service as bundle
|
|
|
|
|
copy:
|
2022-07-04 02:58:24 +02:00
|
|
|
|
dest: '{{ s6_etc_dir }}/service/{{ item }}/type'
|
2020-09-14 03:52:49 +02:00
|
|
|
|
content: bundle
|
|
|
|
|
owner: root
|
|
|
|
|
group: wheel
|
|
|
|
|
mode: 0444
|
|
|
|
|
notify:
|
|
|
|
|
- Reload s6-rc
|
|
|
|
|
with_items:
|
|
|
|
|
- bhyve
|
|
|
|
|
- bhyve-enabled
|
|
|
|
|
- bhyve-disabled
|
|
|
|
|
|
|
|
|
|
- name: Define bhyve service bundles
|
|
|
|
|
template:
|
2022-07-04 02:58:24 +02:00
|
|
|
|
dest: '{{ s6_etc_dir }}/service/{{ item }}/contents'
|
2020-09-14 03:52:49 +02:00
|
|
|
|
src: '{{ item }}-contents.j2'
|
|
|
|
|
owner: root
|
|
|
|
|
group: wheel
|
|
|
|
|
mode: 0444
|
|
|
|
|
notify:
|
|
|
|
|
- Reload s6-rc
|
|
|
|
|
with_items:
|
|
|
|
|
- bhyve
|
|
|
|
|
- bhyve-enabled
|
|
|
|
|
- bhyve-disabled
|
|
|
|
|
|
|
|
|
|
- name: Flush handlers (again)
|
|
|
|
|
meta: flush_handlers
|
|
|
|
|
|
|
|
|
|
- name: Stop disabled bhyve guests
|
|
|
|
|
command: >
|
2022-07-04 02:58:24 +02:00
|
|
|
|
fdmove -c 2 1 s6-rc -l {{ s6_live_dir }} -v 2 -d change bhyve-disabled
|
2020-09-14 03:52:49 +02:00
|
|
|
|
register: change
|
|
|
|
|
changed_when: change.stdout | length > 0
|
2020-09-17 02:38:24 +02:00
|
|
|
|
|
|
|
|
|
- name: Autostart enabled bhyve guests
|
|
|
|
|
lineinfile:
|
2022-07-04 02:58:24 +02:00
|
|
|
|
path: '{{ s6_etc_dir }}/service/enabled/contents'
|
2020-09-17 02:38:24 +02:00
|
|
|
|
regexp: '^bhyve-enabled$'
|
|
|
|
|
line: 'bhyve-enabled'
|
|
|
|
|
notify:
|
|
|
|
|
- Reload s6-rc
|