From a665f309863fa4c8fb3239974d9f6c8c3ad46ce5 Mon Sep 17 00:00:00 2001 From: Arden Shackelford Date: Fri, 2 Feb 2024 04:01:52 -0600 Subject: [PATCH] feat: integrate different install path and owner/group --- defaults/main.yml | 8 ++++++++ tasks/main.yml | 16 ++++++++++------ vars/main.yml | 1 + 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 vars/main.yml diff --git a/defaults/main.yml b/defaults/main.yml index 8b7678e..b8b1ac1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -10,4 +10,12 @@ starship_arch: "{{ ansible_architecture }}" # @var starship_download:description: URL to the archive of the release to install starship_download: "https://github.com/starship/starship/releases/download/v{{ starship_version }}/starship-{{ starship_arch }}-unknown-linux-musl.tar.gz" +# @var starship_install_directory:description: Directory in which to install the Starship binary +starship_install_directory: "/usr/bin" + +# @var starship_owner:description: User who will own the Starship binary file +starship_owner: root + +# @var starship_group:description: Group who will own the Starship binary file +starship_group: root ... diff --git a/tasks/main.yml b/tasks/main.yml index 50ce8c2..166b988 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,17 +1,21 @@ # Standards: 1.2 --- -- name: Check existing install + +- name: Check Existing Install register: starship_version_check failed_when: False changed_when: False check_mode: False - shell: /usr/bin/starship --version 2>&1 + shell: "{{ starship_install_directory }}/starship --version 2>&1" tags: - starship - name: Fact version change + when: + - starship_version_check.stdout_lines is defined + - starship_version not in starship_version_check.stdout_lines[0] set_fact: - starship_version_changed: "{{ starship_version_check.rc != 0 or (starship_version_check.stdout_lines is defined and starship_version not in starship_version_check.stdout_lines[0]) | bool }}" + starship_version_changed: True tags: - starship @@ -20,10 +24,10 @@ - starship_version_changed unarchive: src: "{{ starship_download }}" - dest: /usr/bin + dest: "{{ starship_install_directory }}" remote_src: True - owner: root - group: root + owner: "{{ starship_owner }}" + group: "{{ starship_group }}" tags: - starship diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..93e4f11 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1 @@ +starship_version_changed: False