aboutsummaryrefslogtreecommitdiffstats
path: root/roles/jails/22_forge/tasks/main.yml
blob: 92a29c83d63c8b882612bf76fe7ec68ac9371dc9 (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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
- import_role:
    name: jail
    tasks_from: jail_setup

# --- git user ---

- name: Create git group
  group:
    name: git
    gid: 1000

- name: Create git user
  user:
    name: git
    uid: 1000
    group: git
    home: /var/db/repos
    shell: /usr/local/bin/git-shell
    comment: "Git Server"
    create_home: false

- name: Create .ssh directory for git user
  file:
    path: /var/db/repos/.ssh
    state: directory
    owner: git
    group: git
    mode: "0700"

- name: Deploy authorized_keys
  copy:
    content: "{{ forge_authorized_keys }}\n"
    dest: /var/db/repos/.ssh/authorized_keys
    owner: git
    group: git
    mode: "0600"

- name: Deploy gitconfig for git user
  copy:
    content: |
      [init]
          defaultBranch = main
    dest: /var/db/repos/.gitconfig
    owner: git
    group: git
    mode: "0644"

- name: Deploy SSH config for git user
  copy:
    content: |
      Host *
          IdentityFile ~/.ssh/forge_deploy
          IdentitiesOnly yes
          StrictHostKeyChecking=accept-new
    dest: /var/db/repos/.ssh/config
    owner: git
    group: git
    mode: "0600"

- name: Deploy forge deploy private key
  copy:
    content: "{{ forge_deploy_key.private }}"
    dest: /var/db/repos/.ssh/forge_deploy
    owner: git
    group: git
    mode: "0600"

- name: Deploy forge deploy public key
  copy:
    content: "{{ forge_deploy_key.public }}"
    dest: /var/db/repos/.ssh/forge_deploy.pub
    owner: git
    group: git
    mode: "0644"

# --- git-shell-commands ---

- name: Create git-shell-commands directory
  file:
    path: /var/db/repos/git-shell-commands
    state: directory
    owner: root
    group: wheel
    mode: "0755"

- name: Deploy git-shell-commands
  copy:
    src: "{{ jail_role_dir }}/files/git-shell-commands/{{ item }}"
    dest: "/var/db/repos/git-shell-commands/{{ item }}"
    owner: root
    group: wheel
    mode: "0755"
  loop:
    - help
    - new
    - ls
    - delete
    - rename
    - describe
    - mirror

# --- git mirrors ---

- name: Create git-mirrors log file
  file:
    path: /var/log/git-mirrors.log
    state: touch
    owner: git
    group: git
    mode: "0644"

- name: Deploy git-mirrors script
  copy:
    src: "{{ jail_role_dir }}/files/git-mirrors.sh"
    dest: /usr/local/bin/git-mirrors
    owner: root
    group: wheel
    mode: "0755"

- name: Deploy crontab for git user
  copy:
    content: |
      SHELL=/bin/sh
      PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
      0 * * * * /usr/local/bin/git-mirrors
    dest: /var/cron/tabs/git
    owner: root
    group: wheel
    mode: "0600"

# --- cgit/www config ---

- name: Create /usr/local/etc/git directory
  file:
    path: /usr/local/etc/git
    state: directory
    owner: root
    group: wheel
    mode: "0755"

- name: Deploy gitconfig for www user (safe.directory for cgit/fcgiwrap)
  copy:
    content: |
      [safe]
          directory = *
    dest: /usr/local/etc/git/gitconfig-www
    owner: root
    group: wheel
    mode: "0644"

- name: Create /usr/local/etc/cgit directory
  file:
    path: /usr/local/etc/cgit
    state: directory
    owner: root
    group: wheel
    mode: "0755"

- name: Deploy cgit head-include
  copy:
    src: "{{ jail_role_dir }}/files/head-include.html"
    dest: /usr/local/etc/cgit/head-include.html
    owner: root
    group: wheel
    mode: "0644"

- name: Deploy cgit footer
  copy:
    src: "{{ jail_role_dir }}/files/footer.html"
    dest: /usr/local/etc/cgit/footer.html
    owner: root
    group: wheel
    mode: "0644"

- name: Deploy custom cgit.css
  copy:
    src: "{{ jail_role_dir }}/files/cgit.css"
    dest: /usr/local/www/cgit/cgit.css
    owner: root
    group: wheel
    mode: "0644"

- name: Deploy syntax-highlighting filter
  copy:
    src: "{{ jail_role_dir }}/files/syntax-highlighting.sh"
    dest: /usr/local/lib/cgit/filters/syntax-highlighting.sh
    owner: root
    group: wheel
    mode: "0755"

- name: Deploy custom md2html filter
  copy:
    src: "{{ jail_role_dir }}/files/md2html"
    dest: /usr/local/lib/cgit/filters/html-converters/md2html
    owner: root
    group: wheel
    mode: "0755"

- name: Deploy custom about-formatting filter
  copy:
    src: "{{ jail_role_dir }}/files/about-formatting.sh"
    dest: /usr/local/lib/cgit/filters/about-formatting.sh
    owner: root
    group: wheel
    mode: "0755"

- name: Deploy nginx config
  template:
    src: "{{ jail_role_dir }}/templates/usr_local_etc_nginx_nginx.conf.j2"
    dest: /usr/local/etc/nginx/nginx.conf
    owner: root
    group: wheel
    mode: "0644"
  notify: Reload nginx

- name: Deploy cgitrc
  template:
    src: "{{ jail_role_dir }}/templates/usr_local_etc_cgitrc.j2"
    dest: /usr/local/etc/cgitrc
    owner: root
    group: wheel
    mode: "0644"

- name: Deploy sshd_config
  template:
    src: "{{ jail_role_dir }}/templates/etc_ssh_sshd_config.j2"
    dest: /etc/ssh/sshd_config
    owner: root
    group: wheel
    mode: "0644"
  notify: Restart sshd

- import_role:
    name: jail
    tasks_from: jail_launch