Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible Configuration + Pull Latest Version #13

Merged
merged 6 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3"
Shackelford-Arden marked this conversation as resolved.
Show resolved Hide resolved

tasks:
test:
cmds:
- cmd: molecule test

test-all:
cmds:
- cmd: molecule test --all
8 changes: 8 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
...
12 changes: 6 additions & 6 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
---
- name: Prepare
hosts: all
gather_facts: False
gather_facts: false
Shackelford-Arden marked this conversation as resolved.
Show resolved Hide resolved

tasks:
- name: Wait for aptlock
shell: while fuser /var/lib/apt/lists/lock >/dev/null 2>&1; do echo 'Waiting for apt list lock.' && sleep 10; done
changed_when: False
ansible.builtin.shell: while fuser /var/lib/apt/lists/lock >/dev/null 2>&1; do echo 'Waiting for apt list lock.' && sleep 10; done
changed_when: false

- name: Update package cache
apt:
update_cache: True
ansible.builtin.apt:
update_cache: true

- name: Install gpg dependency
apt:
ansible.builtin.apt:
name: python3-gpg
state: present

Expand Down
28 changes: 16 additions & 12 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
# 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
failed_when: false
changed_when: false
check_mode: false
ansible.builtin.shell: "{{ starship_install_directory }}/starship --version 2>&1"
tags:
- starship

- name: Fact version change
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 }}"
when:
- starship_version_check.stdout_lines is defined
- starship_version not in starship_version_check.stdout_lines[0]
ansible.builtin.set_fact:
starship_version_changed: true
tags:
- starship

- name: Download release binary
when:
- starship_version_changed
unarchive:
ansible.builtin.unarchive:
src: "{{ starship_download }}"
dest: /usr/bin
remote_src: True
owner: root
group: root
dest: "{{ starship_install_directory }}"
remote_src: true
owner: "{{ starship_owner }}"
group: "{{ starship_group }}"
tags:
- starship

Expand Down
1 change: 1 addition & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
starship_version_changed: false