summaryrefslogtreecommitdiff
path: root/roles/git/tasks/main.yml
blob: fffca7c9bd93478647cd7d27aa1b266d845a2412 (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
- name: Install cgit, fcgiwrap, git, and shadow
  community.general.apk:
    name:
      - cgit
      - fcgiwrap
      - git
      - shadow

- name: Add git group
  ansible.builtin.group:
    name: git

- name: Append 'git' group to nginx user
  ansible.builtin.user:
    name: nginx
    groups:
      - git
    append: true

- name: Create git directory in attached storage
  ansible.builtin.file:
    path: /media/seagate/git
    state: directory
    owner: nginx
    group: git
    mode: "750"

- name: Set owners recursively in git directory in attached storage
  ansible.builtin.file:
    path: /media/seagate/git
    state: directory
    owner: nginx
    group: git
    recurse: true

- name: Symlink git directory to /srv/git
  ansible.builtin.file:
    src: /media/seagate/git
    dest: /srv/git
    owner: nginx
    group: git
    state: link
    mode: "750"

- name: Configure fcgiwrap daemon
  register: fcgiwrap_conf
  vars:
    fcgiwrap_socket: /run/fcgiwrap.sock
    fcgiwrap_user: nginx
    fcgiwrap_group: nginx
  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: Install htpasswd file
  ansible.builtin.copy:
    src: htpasswd
    dest: /etc/nginx/.htpasswd
    owner: nginx
    group: nginx
    mode: "400"

- name: Install git.joeac.net nginx site config
  register: cgit_nginx_site
  vars:
    fcgiwrap_socket: /run/fcgiwrap.sock
  ansible.builtin.template:
    src: nginx/git.joeac.net.conf
    dest: /etc/nginx/http.d/git.joeac.net.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: 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 ( 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 /srv/git/* safe in system-wide git config
  register: gitconfig
  community.general.git_config:
    name: safe.directory
    add_mode: add
    value: /srv/git/*

- name: Restart git daemon and configure to start on boot
  when: gitd_conf 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 )
  ansible.builtin.service:
    name: git-daemon
    enabled: true
    state: started