-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitea.yml
114 lines (90 loc) · 2.95 KB
/
gitea.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
- name: Deploy Gitea
hosts: all
become: true
gather_facts: true
vars:
__gitea_version : 1.22.5
__gitea_arch : amd64
__gitea_binary : "https://dl.gitea.io/gitea/{{ __gitea_version }}/\
gitea-{{ __gitea_version }}-linux-{{ __gitea_arch }}"
__gitea_user:
name : gitea
gecos : Git with a cup of tea
shell : /bin/bash
home : /home/gitea
tasks:
- name: Install Git
ansible.builtin.package:
name : git
state : present
- name: Check if Gitea is present and is correct version
ansible.builtin.command : /usr/local/bin/gitea --version
ignore_errors : true
changed_when : false
register : r_check_gitea
- name: Fetch Gitea binary and notify user
when :
- (r_check_gitea.rc == 1 or r_check_gitea.stdout is not search(__gitea_version))
block:
- name: Gitea binary not found or version mismatch
ansible.builtin.debug :
msg : "Gitea binary not found or version mismatch."
- name: "Fetch Gitea {{ __gitea_version }}"
ansible.builtin.get_url :
url : "{{ __gitea_binary }}"
dest : /usr/local/bin/gitea
mode : "0755"
notify : Restart Gitea
- name: Create Gitea user
ansible.builtin.user:
name : "{{ __gitea_user.name }}"
comment : "{{ __gitea_user.gecos }}"
shell : "{{ __gitea_user.shell }}"
home : "{{ __gitea_user.home }}"
create_home : true
state : present
- name: Create required directories
ansible.builtin.file:
path : "{{ item }}"
state : directory
recurse : true
owner : "{{ __gitea_user.name }}"
group : "{{ __gitea_user.name }}"
mode : "0750"
loop:
- /var/lib/gitea/custom
- /var/lib/gitea/data
- /var/lib/gitea/log
- /etc/gitea
- name: Debug ansible_virtualization_type
ansible.builtin.debug:
var: ansible_virtualization_type
verbosity: 1
- name: Manage Gitea service
when:
- not ansible_virtualization_type | regex_search('(podman|docker|container)')
block:
- name: Deploy unit file for Gitea
ansible.builtin.template:
src : templates/gitea.service.j2
dest : /etc/systemd/system/gitea.service
owner : root
group : root
mode : "0644"
- name: Reload Systemd
ansible.builtin.systemd:
daemon_reload: true
- name: Start Gitea
ansible.builtin.service:
name : gitea
state : started
enabled : true
handlers:
- name: Restart Gitea
ansible.builtin.service:
name : gitea
state : restarted
when:
- not ansible_virtualization_type | regex_search('(podman|docker|container)')
...