ansible-role-gitea/tasks/main.yml
Trysdyn Black 3226a76d94 Add toggle to do a version check before download
Old behavior is to download the binary of `gitea_version` every run,
then checksum it against the currently installed version to see if it needs
to be copied over.

New behavior is to attempt to extract the current running version of gitea
and only initiate the old behavior if the running version != `gitea_version`.

Default is old behavior due to the major logic change involved.
2019-04-30 08:55:21 +01:00

54 lines
1.3 KiB
YAML

---
- name: "Check gitea version"
shell: "/usr/local/bin/gitea -v | cut -d' ' -f 3"
register: gitea_active_version
changed_when: false
failed_when: false
when: gitea_version_check
- name: "Download the binary"
get_url:
url: "{{ gitea_dl_url }}/v{{ gitea_version }}/gitea-{{ gitea_version }}-linux-{{ gitea_arch }}"
dest: /usr/local/bin/gitea
owner: root
group: root
mode: 0755
force: true
notify: "Restart gitea"
when: (gitea_version_check == false) or (gitea_active_version.stdout != gitea_version)
- include: create_user.yml
- name: "Create config and data directory"
file:
path: "{{ item }}"
state: directory
owner: "{{ gitea_user }}"
with_items:
- "/etc/gitea"
- "{{ gitea_home }}"
- "{{ gitea_home }}/data"
- "{{ gitea_home }}/custom"
- "{{ gitea_home }}/custom/https"
- "{{ gitea_home }}/custom/mailer"
- include: install_systemd.yml
when: ansible_service_mgr == "systemd"
- name: "Configure gitea"
template:
src: gitea.ini.j2
dest: /etc/gitea/gitea.ini
owner: "{{ gitea_user }}"
mode: 0600
notify: "Restart gitea"
- name: "Service gitea"
service:
name: gitea
state: started
enabled: true
when: ansible_service_mgr == "systemd"
- include: fail2ban.yml
when: gitea_fail2ban_enabled