mirror of
https://github.com/roles-ansible/ansible_role_gitea.git
synced 2024-08-16 11:39:50 +02:00
L3D
446d20c23d
+ Incremented simple version check + Added better error messages for chosing the wrong forgejo version SOLVE https://github.com/roles-ansible/ansible_role_gitea/issues/106
107 lines
4.3 KiB
YAML
107 lines
4.3 KiB
YAML
---
|
|
- name: "Check forgejo installed version"
|
|
ansible.builtin.shell: "set -eo pipefail; {{ gitea_full_executable_path }} -v | cut -d' ' -f 3"
|
|
args:
|
|
executable: /bin/bash
|
|
register: gitea_active_version
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: "Determine 'latest' version release"
|
|
when: gitea_version == "latest"
|
|
block:
|
|
- name: "Get latest forgejo release metadata"
|
|
ansible.builtin.uri:
|
|
url: 'https://codeberg.org/api/v1/repos/forgejo/forgejo/releases?limit=1'
|
|
return_content: true
|
|
register: gitea_forgejo_remote_metadata
|
|
become: false
|
|
when: not ansible_check_mode
|
|
|
|
- name: "Fail if running in check mode without versions set."
|
|
ansible.builtin.fail:
|
|
msg: |
|
|
"You are running this playbook in check mode:
|
|
Please set the Gitea version with the variable 'gitea_version', because the URI module cannot detect the latest version in this mode."
|
|
when: ansible_check_mode and (gitea_version == 'latest' or gitea_version == 'present')
|
|
|
|
- name: "Set fact latest forgejo release"
|
|
ansible.builtin.set_fact:
|
|
gitea_remote_version: "{{ gitea_forgejo_remote_metadata.json.0.tag_name[1:] }}"
|
|
when: not ansible_check_mode
|
|
|
|
- name: "Set forgejo version target (latest)"
|
|
ansible.builtin.set_fact:
|
|
gitea_version_target: "{{ gitea_remote_version }}"
|
|
when: not ansible_check_mode
|
|
|
|
- name: "Set forgejo version target {{ gitea_version }}"
|
|
ansible.builtin.set_fact:
|
|
gitea_version_target: "{{ gitea_version }}"
|
|
when: gitea_version != "latest"
|
|
|
|
- name: "Download forgejo version {{ gitea_version_target }}"
|
|
when: not ansible_check_mode
|
|
block:
|
|
- name: "Get specific forgejo release metadata"
|
|
ansible.builtin.uri:
|
|
url: 'https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/tags/v{{ gitea_version_target }}'
|
|
return_content: true
|
|
register: gitea_forgejo_remote_tags_metadata
|
|
become: false
|
|
rescue:
|
|
- name: "Error Downloading https://codeberg.org/api/v1/repos/forgejo/forgejo/releases/tags/v{{ gitea_version_target }}"
|
|
ansible.builtin.fail:
|
|
msg: "We did not find the forgejo version you specified. Are you sure that '{{ gitea_version_target }}' is a valid forgejo version?"
|
|
|
|
- name: "Generate forgejo download url"
|
|
ansible.builtin.set_fact:
|
|
gitea_forgejo_dl_url: "{{ gitea_forgejo_remote_tags_metadata.json | community.general.json_query(gitea_forgejo_query_download) }}"
|
|
when: not ansible_check_mode
|
|
|
|
- name: "Generate forgejo download checksum url"
|
|
ansible.builtin.set_fact:
|
|
gitea_forgejo_checksum_url: "{{ gitea_forgejo_remote_tags_metadata.json | community.general.json_query(gitea_forgejo_query_checksum) }}"
|
|
when: not ansible_check_mode
|
|
|
|
- name: Get forgejo checksum
|
|
ansible.builtin.uri:
|
|
url: "{{ gitea_forgejo_checksum_url | first }}"
|
|
return_content: true
|
|
register: _gitea_forgejo_dl_checksum
|
|
become: false
|
|
when: not ansible_check_mode
|
|
|
|
- name: Set forjeo checksum
|
|
ansible.builtin.set_fact:
|
|
gitea_forgejo_checksum: "{{ _gitea_forgejo_dl_checksum.content.split(' ')[0] }}"
|
|
when: not ansible_check_mode
|
|
|
|
- name: "Generate forgejo download signed url"
|
|
ansible.builtin.set_fact:
|
|
gitea_forgejo_signed_url: "{{ gitea_forgejo_remote_tags_metadata.json | community.general.json_query(gitea_forgejo_query_signed) }}"
|
|
when: not ansible_check_mode
|
|
|
|
- name: "Set a example forgejo download link if in check mode"
|
|
ansible.builtin.set_fact:
|
|
gitea_forgejo_dl_url: ['https://codeberg.org/attachments/a00333ad-250a-4d30-a764-9a37fb24f419']
|
|
when: ansible_check_mode
|
|
|
|
- name: "Set a example forgejo checksum link if in check mode"
|
|
ansible.builtin.set_fact:
|
|
gitea_forgejo_checksum: 'f8c71464d1b250bf022eaa3df270c810950904ceb71da5cefc7ec24a034a4c87'
|
|
when: ansible_check_mode
|
|
|
|
- name: "Set a example forgejo checksum link if in check mode"
|
|
ansible.builtin.set_fact:
|
|
gitea_forgejo_signed_url: ['https://codeberg.org/attachments/ae5e50c6-e86e-4202-b95f-f142e8138e2f']
|
|
when: ansible_check_mode
|
|
|
|
- name: Show Download URLs
|
|
ansible.builtin.debug:
|
|
msg: "{{ item }}"
|
|
verbosity: 1
|
|
with_items:
|
|
- "gitea_forgejo_dl_url: {{ gitea_forgejo_dl_url | first }}"
|
|
- "gitea_forgejo_checksum: {{ gitea_forgejo_checksum }}"
|
|
- "gitea_forgejo_signed_url: {{ gitea_forgejo_signed_url | first }}"
|