57 lines
2.4 KiB
YAML
57 lines
2.4 KiB
YAML
---
|
|
# task/install_host file for deploy_gitea_runner
|
|
- name: "Get release for gitea_runner:{{ deploy_gitea_runner_version }}"
|
|
vars:
|
|
_gitea_actions_url_ext: "{% if deploy_gitea_runner_version == 'latest'%}releases{% else %}releases/tags{% endif %}"
|
|
ansible.builtin.uri:
|
|
url: "{{ deploy_gitea_runner_gitea_api }}/{{ _gitea_actions_url_ext }}/{{ deploy_gitea_runner_version }}"
|
|
return_content: true
|
|
register: _gitea_runner_new_release
|
|
|
|
- name: "Check if gitea_runner is already installed"
|
|
ansible.builtin.stat:
|
|
path: "{{ deploy_gitea_runner_directory }}/.version"
|
|
changed_when: false
|
|
check_mode: false
|
|
register: _gitea_runner_is_installed
|
|
|
|
- name: "Check current gitea_runner version"
|
|
ansible.builtin.command: "cat {{ deploy_gitea_runner_directory }}/.version"
|
|
register: _gitea_runner_old_release
|
|
check_mode: false
|
|
changed_when: false
|
|
when: _gitea_runner_is_installed.stat.exists
|
|
|
|
- name: "Set facts for wanted gitea_runner release"
|
|
ansible.builtin.set_fact:
|
|
deploy_gitea_runner_wanted_version: "{{ _gitea_runner_new_release.json['tag_name']|regex_replace('v', '') }}"
|
|
when: _gitea_runner_new_release.json is defined
|
|
and (_gitea_runner_new_release.json | length > 0)
|
|
|
|
- name: "Set facts for current gitea_runner release"
|
|
ansible.builtin.set_fact:
|
|
deploy_gitea_runner_current_version: "{{ _gitea_runner_old_release.stdout | regex_replace('v', '') }}"
|
|
when: _gitea_runner_old_release.stdout is defined
|
|
and (_gitea_runner_old_release.stdout | length > 0)
|
|
|
|
- name: "Install gitea_runner"
|
|
when: deploy_gitea_runner_current_version is not defined
|
|
or deploy_gitea_runner_wanted_version not in deploy_gitea_runner_current_version
|
|
block:
|
|
- name: "Download and install gitea_runner version:{{ deploy_gitea_runner_version }}"
|
|
ansible.builtin.get_url:
|
|
url: "{{ deploy_gitea_runner_gitea_url }}/releases/download/v{{ deploy_gitea_runner_wanted_version }}/act_runner-{{ deploy_gitea_runner_wanted_version }}-linux-{{ deploy_gitea_runner_arch_map[ansible_architecture] }}"
|
|
dest: "{{ deploy_gitea_runner_path }}"
|
|
force: true
|
|
owner: root
|
|
group: root
|
|
mode: '0755'
|
|
notify:
|
|
- systemctl-restart-gitea-runner
|
|
|
|
- name: "Update version file"
|
|
ansible.builtin.copy:
|
|
content: "{{ deploy_gitea_runner_wanted_version }}"
|
|
dest: "{{ deploy_gitea_runner_directory }}/.version"
|
|
mode: "0600"
|