From a51aa730212edc3dd6b03922fde8378d0a8f154f Mon Sep 17 00:00:00 2001 From: Bas Meijer Date: Wed, 13 Nov 2024 10:41:57 +0100 Subject: [PATCH] on-prem install --- inventory/dev/group_vars/semaphore.yml | 2 ++ roles/semaphore/defaults/main.yml | 1 + roles/semaphore/tasks/present.yml | 25 ++++++++++++++++++------- roles/semaphore/vars/main.yml | 1 + 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/inventory/dev/group_vars/semaphore.yml b/inventory/dev/group_vars/semaphore.yml index 90ca90e..dd71d58 100644 --- a/inventory/dev/group_vars/semaphore.yml +++ b/inventory/dev/group_vars/semaphore.yml @@ -1,4 +1,6 @@ --- +semaphore_download_url: 'https://github.com/semaphoreui/semaphore/releases/download/v2.10.35/semaphore_2.10.35_linux_amd64.tar.gz' +semaphore_download_binary: false semaphore_web_root: 'https://controller' semaphore_db_host: '127.0.0.1' controller_repository_name: "example-repo" diff --git a/roles/semaphore/defaults/main.yml b/roles/semaphore/defaults/main.yml index fe83246..e88d49f 100644 --- a/roles/semaphore/defaults/main.yml +++ b/roles/semaphore/defaults/main.yml @@ -1,5 +1,6 @@ --- desired_state: present +semaphore_download_binary: true verify_state: true # Easier debugging debug: false diff --git a/roles/semaphore/tasks/present.yml b/roles/semaphore/tasks/present.yml index 99147c1..f257cc7 100644 --- a/roles/semaphore/tasks/present.yml +++ b/roles/semaphore/tasks/present.yml @@ -29,18 +29,28 @@ group: semaphore mode: '0600' -- name: Get Semaphore Release info from Github - ansible.builtin.uri: - url: https://api.github.com/repos/semaphoreui/semaphore/releases/latest - return_content: true - body_format: json - register: semaphore_release +- name: Find Semaphore release + when: semaphore_download_url is not defined + block: + + - name: Get Semaphore Release info from Github + ansible.builtin.uri: + url: https://api.github.com/repos/semaphoreui/semaphore/releases/latest + return_content: true + body_format: json + register: _sem_rel + + - name: Set semaphore_download_url + ansible.builtin.set_fact: + semaphore_download_url: "{{ semaphore_releases_url }}/{{ _sem_rel.json.name }}/semaphore_{{ _sem_rel.json.name[1:] }}_linux_amd64.tar.gz" - name: Install Semaphore binary + when: semaphore_download_binary | bool block: + - name: Download semaphore ansible.builtin.get_url: - url: https://github.com/semaphoreui/semaphore/releases/download/{{ semaphore_release.json.name }}/semaphore_{{ semaphore_release.json.name[1:] }}_linux_amd64.tar.gz + url: "{{ semaphore_download_url }}" dest: /tmp/semaphore.tar.gz mode: '0755' @@ -101,6 +111,7 @@ become_user: semaphore ansible.builtin.command: cmd: ansible-galaxy collection install --upgrade -r /home/semaphore/requirements.yml + changed_when: true - name: Check if env file exists ansible.builtin.stat: diff --git a/roles/semaphore/vars/main.yml b/roles/semaphore/vars/main.yml index ee517dd..e84d554 100644 --- a/roles/semaphore/vars/main.yml +++ b/roles/semaphore/vars/main.yml @@ -1,4 +1,5 @@ --- +semaphore_releases_url: 'https://github.com/semaphoreui/semaphore/releases/download' semaphore_admin_password: "{{ vault_admin_password }}" semaphore_cookie_hash: "{{ vault_cookie_hash }}" semaphore_cookie_encryption: "{{ vault_cookie_encryption }}"