- update gitea.yml for ansible-lint compliance

- upgrade gitea 1.20.2 -> 1.20.3
This commit is contained in:
Chris Hammer 2023-09-06 12:54:05 -04:00
parent 4212fa6ea4
commit 4f20c8f4a5
2 changed files with 36 additions and 28 deletions

5
.ansible-lint Normal file
View File

@ -0,0 +1,5 @@
skip_list:
- yaml[colons]
- yaml[empty-lines]
- yaml[line-length]
- no-changed-when

View File

@ -1,12 +1,12 @@
---
- name: Deploy Gitea
hosts: gitea
become: yes
gather_facts: no
become: true
gather_facts: false
vars:
__gitea_version : 1.20.2
__gitea_version : 1.20.3
__gitea_arch : amd64
__gitea_binary : "https://dl.gitea.io/gitea/{{ __gitea_version }}/\
gitea-{{ __gitea_version }}-linux-{{ __gitea_arch }}"
@ -20,57 +20,53 @@
tasks:
- name: Install Git
package :
ansible.builtin.package:
name : git
state : present
- name: Check if Gitea is present and is correct version
command : /usr/local/bin/gitea --version
ignore_errors : yes
changed_when : no
ansible.builtin.command : /usr/local/bin/gitea --version
ignore_errors : true
changed_when : false
register : r_check_gitea
- name: Debug r_check_gitea
debug:
var: r_check_gitea.stdout
- name: Gitea presence and version verification
debug :
ansible.builtin.debug :
msg : "Gitea binary not found or version mismatch."
when :
- (r_check_gitea.rc == 1 or r_check_gitea.stdout is not search(__gitea_version))
- name: "Fetch Gitea {{ __gitea_version }}"
get_url :
ansible.builtin.get_url :
url : "{{ __gitea_binary }}"
dest : /usr/local/bin/gitea
mode : 0755
mode : "0755"
notify : Restart Gitea
when :
- (r_check_gitea.rc == 1 or r_check_gitea.stdout is not search(__gitea_version))
- name: Create Gitea user
user:
name : "{{ __gitea_user.name }}"
ansible.builtin.user:
name : "{{ __gitea_user.name }}"
comment : "{{ __gitea_user.gecos }}"
shell : "{{ __gitea_user.shell }}"
home : "{{ __gitea_user.home }}"
create_home : yes
home : "{{ __gitea_user.home }}"
create_home : true
state : present
- name: Create required directories
file:
ansible.builtin.file:
path : "{{ item }}"
state : directory
recurse : yes
recurse : true
owner : "{{ __gitea_user.name }}"
group : "{{ __gitea_user.name }}"
mode : 0750
mode : "0750"
loop:
- /var/lib/gitea/custom
- /var/lib/gitea/data
@ -79,24 +75,31 @@
- name: Deploy unit file for Gitea
template:
ansible.builtin.template:
src : templates/gitea.service.j2
dest : /etc/systemd/system/gitea.service
owner : root
group : root
mode : 0644
mode : "0644"
- name: Reload Systemd
systemd:
daemon_reload: yes
ansible.builtin.systemd:
daemon_reload: true
- name: Start Gitea
service:
ansible.builtin.service:
name : gitea
state : started
enabled : yes
enabled : true
handlers:
- name: Restart Gitea
ansible.builtin.service:
name : gitea
state : restarted
...