blob: 67083f79762f7af566eca8456f6f8008ca55421c (
plain)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
- name: Install cgit, fcgiwrap, git, nginx, and shadow
community.general.apk:
name:
- cgit
- fcgiwrap
- git
- nginx
- shadow
- name: Add git group
ansible.builtin.group:
name: git
- name: Add git user
ansible.builtin.user:
name: git
group: git
- name: Find existing shells
register: existing_shells
changed_when: false
ansible.builtin.command: cat /etc/shells
- name: Add git-shell to /etc/shells
when: "'/git-shell' not in existing_shells.stdout"
ansible.builtin.shell: which git-shell >> /etc/shells
- name: Find current git login shell
register: current_git_login_shell
ansible.builtin.shell: "cat /etc/passwd | grep ^git: | grep -o [^:]*$"
- name: Set git login shell to git-shell
when: "'git-shell' not in current_git_login_shell"
ansible.builtin.shell: chsh -s $(which git-shell) git
- name: Create fcgiwrap user and append 'git' group
ansible.builtin.user:
name: "{{ fcgiwrap_user }}"
group: "{{ fcgiwrap_group }}"
groups:
- git
append: true
- name: Create git directory in attached storage
ansible.builtin.file:
path: /media/seagate/git
state: directory
owner: git
group: git
mode: "750"
- name: Symlink git directory to /srv/git
ansible.builtin.file:
src: /media/seagate/git
dest: /srv/git
owner: git
group: git
state: link
mode: "750"
- name: Configure fcgiwrap daemon
register: fcgiwrap_conf
ansible.builtin.template:
src: conf.d/fcgiwrap
dest: /etc/conf.d/fcgiwrap
mode: "644"
- name: Restart fcgiwrap daemon and configure to start on boot
when: fcgiwrap_conf is changed
ansible.builtin.service:
name: fcgiwrap
enabled: true
state: restarted
- name: Start fcgiwrap daemon and configure to start on boot
when: not ( fcgiwrap_conf is changed )
ansible.builtin.service:
name: fcgiwrap
enabled: true
state: started
- name: Remove default nginx site config
register: default_nginx_site
ansible.builtin.file:
path: /etc/nginx/http.d/default.conf
state: absent
- name: Install cgit nginx site config
register: cgit_nginx_site
ansible.builtin.template:
src: nginx/cgit.conf
dest: /etc/nginx/http.d/cgit.conf
owner: nginx
group: nginx
mode: "660"
- name: Create git.joeac.net nginx log directory
ansible.builtin.file:
path: /var/log/nginx/git.joeac.net
state: directory
- name: Restart nginx daemon and configure to start on boot
when: default_nginx_site is changed or cgit_nginx_site is changed
ansible.builtin.service:
name: nginx
enabled: true
state: restarted
- name: Start nginx daemon and configure to start on boot
when: not ( default_nginx_site is changed or cgit_nginx_site is changed )
ansible.builtin.service:
name: nginx
enabled: true
state: started
- name: Install cgit config
ansible.builtin.copy:
src: cgitrc
dest: /etc/cgitrc
mode: "+r"
- name: Install git daemon
community.general.apk:
name: git-daemon-openrc
- name: Configure git daemon
register: gitd_conf
ansible.builtin.template:
src: conf.d/git-daemon
dest: /etc/conf.d/git-daemon
- name: Create gitd user
ansible.builtin.user:
name: gitd
group: git
- name: Mark git directory safe for gitd git operations
register: gitd_gitconfig
ansible.builtin.copy:
src: .gitconfig
dest: ~gitd/.gitconfig
owner: gitd
group: git
mode: "644"
- name: Restart git daemon and configure to start on boot
when: gitd_conf is changed or gitd_gitconfig is changed
ansible.builtin.service:
name: git-daemon
enabled: true
state: restarted
- name: Start git daemon and configure to start on boot
when: not ( gitd_conf is changed or gitd_gitconfig is changed )
ansible.builtin.service:
name: git-daemon
enabled: true
state: started
|