2022-01-10 09:01:52 +01:00
|
|
|
---
|
2023-04-25 16:25:50 +02:00
|
|
|
- name: Dependency block
|
|
|
|
block:
|
2022-01-10 09:01:52 +01:00
|
|
|
- name: Update apt cache
|
2023-04-25 16:25:50 +02:00
|
|
|
become: true
|
|
|
|
ansible.builtin.apt:
|
2022-01-10 09:01:52 +01:00
|
|
|
cache_valid_time: 3600
|
|
|
|
update_cache: true
|
|
|
|
register: _pre_update_apt_cache
|
|
|
|
until: _pre_update_apt_cache is succeeded
|
|
|
|
when:
|
|
|
|
- ansible_pkg_mgr == "apt"
|
|
|
|
|
|
|
|
- name: Install dependencies
|
2023-04-25 16:25:50 +02:00
|
|
|
become: true
|
|
|
|
ansible.builtin.package:
|
2022-01-10 09:01:52 +01:00
|
|
|
name: "{{ gitea_dependencies }}"
|
|
|
|
state: present
|
|
|
|
register: _install_dep_packages
|
|
|
|
until: _install_dep_packages is succeeded
|
|
|
|
retries: 5
|
|
|
|
delay: 2
|
|
|
|
|
2023-04-25 16:25:50 +02:00
|
|
|
- name: Install gitea block
|
|
|
|
when: (not gitea_version_check | bool) or (not ansible_check_mode and (gitea_active_version.stdout != gitea_version_target))
|
|
|
|
block:
|
2022-01-10 09:01:52 +01:00
|
|
|
- name: Download gitea archive
|
2023-04-25 16:25:50 +02:00
|
|
|
ansible.builtin.get_url:
|
2022-01-10 09:01:52 +01:00
|
|
|
url: "{{ gitea_dl_url }}.xz"
|
2023-04-25 16:25:50 +02:00
|
|
|
dest: "/tmp/{{ gitea_filename }}.xz"
|
2022-01-10 09:01:52 +01:00
|
|
|
checksum: "sha256:{{ gitea_dl_url }}.xz.sha256"
|
2023-04-25 16:25:50 +02:00
|
|
|
mode: 0640
|
2022-01-10 09:01:52 +01:00
|
|
|
register: _download_archive
|
2023-04-25 16:25:50 +02:00
|
|
|
become: false
|
2022-01-10 09:01:52 +01:00
|
|
|
until: _download_archive is succeeded
|
|
|
|
retries: 5
|
|
|
|
delay: 2
|
|
|
|
|
|
|
|
- name: Download gitea asc file
|
2023-04-25 16:25:50 +02:00
|
|
|
ansible.builtin.get_url:
|
2022-01-10 09:01:52 +01:00
|
|
|
url: "{{ gitea_dl_url }}.xz.asc"
|
2023-04-25 16:25:50 +02:00
|
|
|
dest: "/tmp/{{ gitea_filename }}.xz.asc"
|
|
|
|
mode: 0640
|
2022-01-10 09:01:52 +01:00
|
|
|
register: _download_asc
|
2023-04-25 16:25:50 +02:00
|
|
|
become: false
|
2022-01-10 09:01:52 +01:00
|
|
|
until: _download_asc is succeeded
|
|
|
|
retries: 5
|
|
|
|
delay: 2
|
|
|
|
|
|
|
|
- name: Check gitea gpg key
|
2023-04-25 16:25:50 +02:00
|
|
|
ansible.builtin.command: "gpg --list-keys 0x{{ gitea_gpg_key }}"
|
2022-01-10 09:01:52 +01:00
|
|
|
register: _gitea_gpg_key_status
|
|
|
|
changed_when: false
|
|
|
|
failed_when: _gitea_gpg_key_status.rc not in (0, 2)
|
|
|
|
|
2023-04-25 16:25:50 +02:00
|
|
|
- name: Print gpg key staus on verbosity
|
|
|
|
ansible.builtin.debug:
|
|
|
|
msg: "{{ _gitea_gpg_key_status.stdout }}"
|
|
|
|
verbosity: 1
|
|
|
|
|
2022-01-10 09:01:52 +01:00
|
|
|
- name: Import gitea gpg key
|
2023-04-25 16:25:50 +02:00
|
|
|
ansible.builtin.command: "gpg --keyserver {{ gitea_gpg_server }} --recv {{ gitea_gpg_key }}"
|
2022-01-10 09:01:52 +01:00
|
|
|
register: _gitea_import_key
|
2023-04-25 16:25:50 +02:00
|
|
|
become: false
|
2022-01-10 09:01:52 +01:00
|
|
|
changed_when: '"imported: 1" in _gitea_import_key.stderr'
|
2023-04-25 16:25:50 +02:00
|
|
|
when: '_gitea_gpg_key_status.rc != 0 or "expired" in _gitea_gpg_key_status.stdout'
|
2022-01-10 09:01:52 +01:00
|
|
|
|
|
|
|
- name: Check archive signature
|
2023-04-25 16:25:50 +02:00
|
|
|
ansible.builtin.command: "gpg --verify /tmp/{{ gitea_filename }}.xz.asc /tmp/{{ gitea_filename }}.xz"
|
2022-01-10 09:01:52 +01:00
|
|
|
changed_when: false
|
2023-07-19 19:36:11 +02:00
|
|
|
become: false
|
2022-01-10 09:01:52 +01:00
|
|
|
|
|
|
|
- name: Unpack gitea binary
|
2023-04-25 16:25:50 +02:00
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: "xz -k -d /tmp/{{ gitea_filename }}.xz"
|
|
|
|
creates: "/tmp/{{ gitea_filename }}"
|
2022-01-10 09:01:52 +01:00
|
|
|
|
|
|
|
- name: Propagate gitea binary
|
2023-04-25 16:25:50 +02:00
|
|
|
become: true
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: "/tmp/{{ gitea_filename }}"
|
2022-01-10 09:01:52 +01:00
|
|
|
remote_src: true
|
2023-04-25 16:25:50 +02:00
|
|
|
dest: "{{ gitea_full_executable_path }}"
|
2022-01-10 09:01:52 +01:00
|
|
|
mode: 0755
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
notify: "Restart gitea"
|