From 7862b34711c45430b78c0c10b2b132d78dea911e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Mon, 26 Apr 2021 10:37:28 +0200 Subject: bhyve: Use default and cleaner control --- roles/bhyve/defaults/main.yml | 15 +++++++++++++++ roles/bhyve/tasks/main.yml | 9 ++++----- roles/bhyve/vars/main.yml | 15 --------------- 3 files changed, 19 insertions(+), 20 deletions(-) create mode 100644 roles/bhyve/defaults/main.yml delete mode 100644 roles/bhyve/vars/main.yml (limited to 'roles') diff --git a/roles/bhyve/defaults/main.yml b/roles/bhyve/defaults/main.yml new file mode 100644 index 0000000..c237cac --- /dev/null +++ b/roles/bhyve/defaults/main.yml @@ -0,0 +1,15 @@ + +# bhyve ~~ roles/bhyve/defaults/main.yml +# main variables for all bhyve tasks + +--- + +bhyve_dir: "/data/bhyve" +bhyve_user: "bhyve" +bhyve_group: "bhyve" +bhyve_bootdelay: "3" +bhyve_strict: true + +bhyve_iso: + - https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/x86_64/alpine-virt-3.13.0-x86_64.iso + - https://cdn.openbsd.org/pub/OpenBSD/6.8/amd64/cd68.iso diff --git a/roles/bhyve/tasks/main.yml b/roles/bhyve/tasks/main.yml index 03d2d96..f47be53 100644 --- a/roles/bhyve/tasks/main.yml +++ b/roles/bhyve/tasks/main.yml @@ -68,18 +68,17 @@ dest: "{{ bhyve_dir }}/.iso" loop: "{{ bhyve_iso }}" -- name: retrieve all deprecated vms +- name: retrieve all active vms find: path: "{{ bhyve_dir }}" file_type: directory - register: deprecated_vms + register: active_vms - name: delete all deprecated vms file: path: "{{ item[1].path }}" state: absent - when: (item[1].path | basename) not in "{{ valid_vms }}" + when: bhyve_strict and (item[1].path | basename) not in "{{ valid_vms }}" with_nested: - "{{ vms }}" - - "{{ deprecated_vms.files }}" - + - "{{ active_vms.files }}" diff --git a/roles/bhyve/vars/main.yml b/roles/bhyve/vars/main.yml deleted file mode 100644 index bb78f0d..0000000 --- a/roles/bhyve/vars/main.yml +++ /dev/null @@ -1,15 +0,0 @@ - -# bhyve ~~ roles/bhyve/vars/main.yml -# main variables for all bhyve tasks - ---- - -bhyve_dir: "/data/bhyve" -bhyve_user: "bhyve" -bhyve_group: "bhyve" -bhyve_bootdelay: "3" - -bhyve_iso: - - https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/x86_64/alpine-virt-3.13.0-x86_64.iso - - https://cdn.openbsd.org/pub/OpenBSD/6.8/amd64/cd68.iso - -- cgit v1.2.3