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