From 038297f224511af532028b88a60510c722dba8e1 Mon Sep 17 00:00:00 2001 From: Steve Moyer Date: Tue, 7 Jul 2020 14:22:30 -0400 Subject: [PATCH] Adds the checksum subscript var. Also reliably verifies that required vars are present and clears them after the associated subscript is done. References #206 --- clear_subscript_vars.yml | 6 ++++++ debug_subscript_vars.yml | 6 ++++++ install_from_archive.yml | 27 ++++++++++++++++++++++++++- require_subscript_vars.yml | 7 +++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 clear_subscript_vars.yml create mode 100644 debug_subscript_vars.yml create mode 100644 require_subscript_vars.yml diff --git a/clear_subscript_vars.yml b/clear_subscript_vars.yml new file mode 100644 index 00000000..b1b60e91 --- /dev/null +++ b/clear_subscript_vars.yml @@ -0,0 +1,6 @@ +--- + +- name: "clear the project's subscript variables" + set_fact: + "{{ item.name }}": + with_items: "{{ subscript_vars }}" diff --git a/debug_subscript_vars.yml b/debug_subscript_vars.yml new file mode 100644 index 00000000..b576661e --- /dev/null +++ b/debug_subscript_vars.yml @@ -0,0 +1,6 @@ +--- + +- name: "debug the project's subscript variables" + debug: + var: "{{ item.name }}" + with_items: "{{ subscript_vars }}" diff --git a/install_from_archive.yml b/install_from_archive.yml index 1ebe5715..930b2b11 100644 --- a/install_from_archive.yml +++ b/install_from_archive.yml @@ -11,7 +11,7 @@ # name of the directory (in /opt) where the application # is finally installed. # -# name: The application's formal name. +# title: The application's formal name. # # version: This value indicates what version should be downloaded # and is generally set in the "workstation_versions.yml" @@ -23,6 +23,9 @@ # Optional variables: # -------- --------- # +# checksum: The URL of the file containing a checksum for the archive +# which will be downloaded by this playbook. +# # archive_path: If the archive includes a path prefix for each file, This # value allows the archive to be "relocated" to a directory # named by the version. If this variable is empty, the @@ -34,6 +37,26 @@ # no templating is performed. # +- name: "defines the github variables above" + set_fact: + subscript_vars: + - name: "archive_path" + required: false + - name: "checksum" + required: false + - name: "desktop_file" + required: false + - name: "key" + required: true + - name: "title" + required: true + - name: "url" + required: true + - name: "version" + required: true + +- include: "./require_subscript_vars.yml" + - name: "calculate the installation and final directories for {{ title }}" set_fact: installation_directory: "/opt/{{ key }}" @@ -72,3 +95,5 @@ src: "{{ desktop_file }}" dest: "/usr/share/applications" when: "desktop_file != ''" + +- include: "./clear_subscript_vars.yml" diff --git a/require_subscript_vars.yml b/require_subscript_vars.yml new file mode 100644 index 00000000..49b4f5a6 --- /dev/null +++ b/require_subscript_vars.yml @@ -0,0 +1,7 @@ +--- + +- name: "verifies that the required subscript variables are set" + assert: + that: "not {{ item.required }} or {{ item.name }} != ''" + quiet: true + with_items: "{{ subscript_vars }}"