aboutsummaryrefslogtreecommitdiffstats
path: root/roles/vmm/tasks/isos.yml
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2020-12-02 18:36:25 +0100
committerbinary <me@rgoncalves.se>2020-12-02 18:36:25 +0100
commitc4edd14b8aaf65d1db86074b0109b89ae609d4b3 (patch)
tree94e123449ce228ce1bff2dcb701f72956b1ad72c /roles/vmm/tasks/isos.yml
parent8478e90356b6738a13eed3878000d0e112074960 (diff)
downloadinfrastructure-c4edd14b8aaf65d1db86074b0109b89ae609d4b3.tar.gz
Refactor based on bhyve setup
Diffstat (limited to 'roles/vmm/tasks/isos.yml')
-rw-r--r--roles/vmm/tasks/isos.yml45
1 files changed, 45 insertions, 0 deletions
diff --git a/roles/vmm/tasks/isos.yml b/roles/vmm/tasks/isos.yml
new file mode 100644
index 0000000..946b659
--- /dev/null
+++ b/roles/vmm/tasks/isos.yml
@@ -0,0 +1,45 @@
+
+# vmm isos ~~ roles/vmm/tasks/isos.yml
+# download an iso file to hypervisor.
+
+---
+
+- name: Check arguments
+ fail:
+ msg: "arguments : iso"
+ when: iso is not defined
+
+- name: ensure guest exists
+ set_fact:
+ disk_file: "{{ vmm.disk_dir }}/{{ guest }}.{{ vmm.disk_format }}"
+ when: guest is defined
+
+- name: generate iso infos 1/2
+ set_fact:
+ iso_latest: "{{ vmm.iso_dir }}/{{ vmm.iso[iso].name }}-latest.iso"
+ when: iso is defined
+
+- name: generate iso infos 2/2
+ set_fact:
+ iso_file: "{{ iso_latest | regex_replace('latest', vmm.iso[iso].version) }}"
+ iso_url: "{{ vmm.iso[iso].url \
+ | regex_replace('VERSIONDIR', vmm.iso[iso].versiondir) \
+ | regex_replace('VERSION', vmm.iso[iso].version) }}"
+ iso_checksum: "{{ vmm.iso[iso].sha256 \
+ | regex_replace('VERSIONDIR', vmm.iso[iso].versiondir) \
+ | regex_replace('VERSION', vmm.iso[iso].version) }}"
+ when: iso is defined
+
+- name: Get latest iso
+ get_url:
+ url: "{{ iso_url }}"
+ dest: "{{ iso_file }}"
+ force: "{{ force | default('no') }}"
+ checksum: "sha256:{{ iso_checksum }}"
+
+- name: Symlink latest iso
+ file:
+ src: "{{ iso_file }}"
+ dest: "{{ iso_latest }}"
+ state: link
+
remember that computers suck.