From f93d492be462e263b4b6929aaeec1bc9beab4829 Mon Sep 17 00:00:00 2001 From: L3D Date: Tue, 30 Jun 2020 17:07:25 +0200 Subject: [PATCH] Download binary --- defaults/main.yml | 7 ++++++- tasks/install.yml | 20 ++++++++++++++++++++ tasks/main.yml | 3 +++ tasks/packages.yml | 6 ++++++ vars/main.yml | 13 +++++++++++-- 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 tasks/install.yml create mode 100644 tasks/packages.yml diff --git a/defaults/main.yml b/defaults/main.yml index aeff860..db5909e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,12 @@ --- # default variables grafana_kiosk: - foo: bar + git_release: 'v1.0.2' + git_url: 'https://github.com/grafana/grafana-kiosk' + install_requirements: true + required_packages: [] + install_state: 'present' + architecture: 'autodetect' # perform basic versionscheck? submodules_versioncheck: false diff --git a/tasks/install.yml b/tasks/install.yml new file mode 100644 index 0000000..1108dba --- /dev/null +++ b/tasks/install.yml @@ -0,0 +1,20 @@ +--- +- name: generate download URL for detected architecture + set_fact: + _download_url: "{{ grafana_kiosk.git_url }}/releases/download/{{ grafana_kiosk.git_release }}/{{ _dl_matrix[ansible_architecture] }}" + when: grafana_kiosk.architecture == 'autodetect' + +- name: generate download URL for predefined architecture + set_fact: + _download_url: "{{ grafana_kiosk.git_url }}/releases/download/{{ grafana_kiosk.git_release }}/grafana-kiosk.linux.{{ grafana_kiosk.architecture }}" + when: not grafana_kiosk.architecture == 'autodetect' + +- name: download grafana-kiosk binary + become: true + get_url: + url: "{{ _download_url }}" + dest: /usr/bin/grafana-kiosk + owner: root + group: root + mode: 0755 + force: true diff --git a/tasks/main.yml b/tasks/main.yml index 54c10bf..b2b64d1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,4 +6,7 @@ - include_tasks: versioncheck.yml when: submodules_versioncheck|bool +- include_tasks: packages.yml + when: grafana_kiosk.install_requirements | bool +- include_tasks: install.yml diff --git a/tasks/packages.yml b/tasks/packages.yml new file mode 100644 index 0000000..eb44bb2 --- /dev/null +++ b/tasks/packages.yml @@ -0,0 +1,6 @@ +--- +- name: install requirements for grafana-kiosk + become: true + package: + name: "{{ grafana_kiosk.required_packages }}" + state: "{{ grafana_kiosk.install_state }}" diff --git a/vars/main.yml b/vars/main.yml index cb250f2..003a0a1 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,6 +1,15 @@ --- _grafana_kiosk: - foo: bar + install_requirements: true + required_packages: [] + install_state: 'present' -playbook_version_number: 1 # should be an integer +_dl_matrix: + 'x86_64': "grafana-kiosk.linux.amd64" + 'i386': "grafana-kiosk.linux.386" + 'armv7l': "grafana-kiosk.linux.armv7" + 'armv6l': "grafana-kiosk.linux.armv6" + 'armv5l': "grafana-kiosk.linux.armv5" + +playbook_version_number: 2 # should be an integer playbook_version_path: 'role-grafana-kiosk_roles-ansible_github.com.version' # unique string