aboutsummaryrefslogtreecommitdiffstats
path: root/roles/obsd_cgit/tasks/main.yml
blob: 7833cc315d62941e36923ebba372402bedda561e (plain) (blame)
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
- name: Install cgit
  community.general.openbsd_pkg:
    name: cgit
    state: present

- name: Create cgit directories
  ansible.builtin.file:
    path: "{{ obsd_cgit_chroot }}{{ item }}"
    state: directory
    owner: www
    group: www
    mode: "0755"
  loop:
    - "{{ obsd_cgit_cache_dir }}"
    - "{{ obsd_cgit_htdocs_dir }}"
    - "{{ obsd_cgit_htdocs_dir }}/cgi-bin"

- name: Check if original cgi-bin exists
  ansible.builtin.stat:
    path: "{{ obsd_cgit_chroot }}/cgi-bin/cgit.cgi"
  register: obsd_cgit_cgi_stat

- name: Move cgi-bin file from installation to htdocs
  ansible.builtin.copy:
    src: "{{ obsd_cgit_chroot }}/cgi-bin/cgit.cgi"
    dest: "{{ obsd_cgit_chroot }}{{ obsd_cgit_htdocs_dir }}/cgi-bin/cgit.cgi"
    remote_src: true
    owner: www
    group: www
    mode: "0755"
  when: obsd_cgit_cgi_stat.stat.exists

- name: Remove original cgit.cgi
  ansible.builtin.file:
    path: "{{ obsd_cgit_chroot }}/cgi-bin/cgit.cgi"
    state: absent

- name: Check if original cgit dir exists
  ansible.builtin.stat:
    path: "{{ obsd_cgit_chroot }}/cgit"
  register: obsd_cgit_cgit_stat

- name: Move cgit static files from installation to htdocs
  ansible.builtin.copy:
    src: "{{ obsd_cgit_chroot }}/cgit/"
    dest: "{{ obsd_cgit_chroot }}{{ obsd_cgit_htdocs_dir }}/"
    remote_src: true
    owner: www
    group: www
    mode: "0644"
  when: obsd_cgit_cgit_stat.stat.exists

- name: Remove original cgit static files
  ansible.builtin.file:
    path: "{{ obsd_cgit_chroot }}/cgit"
    state: absent

- name: Copy extra static files into chroot htdocs dir
  ansible.builtin.copy:
    src: "{{ item }}"
    dest: "{{ obsd_cgit_chroot }}{{ obsd_cgit_htdocs_dir }}/{{ item }}"
    owner: www
    group: www
    mode: "0644"
  loop:
    - cgit.css
    - footer.html

- name: Copy cgitrc configuration into chroot
  ansible.builtin.template:
    src: cgitrc.j2
    dest: "{{ obsd_cgit_chroot }}/conf/cgitrc"
    owner: www
    group: www
    mode: "0644"

- name: Compile markdown renderer into chroot
  ansible.builtin.include_tasks: markdown.yml

- name: Deploy cgit post-receive hook
  ansible.builtin.copy:
    src: post-receive.d/cgit
    dest: "{{ obsd_cgit_hooks_dir }}/post-receive.d/cgit"
    owner: "{{ obsd_cgit_git_user }}"
    group: "{{ obsd_cgit_git_user }}"
    mode: "0755"

- name: Enable slowcgi
  ansible.builtin.service:
    name: slowcgi
    enabled: true

- name: Deploy cgit vhost fragment
  ansible.builtin.template:
    src: httpd.d/git.conf.j2
    dest: "{{ obsd_httpd_conf_d }}/git.conf"
    owner: root
    group: wheel
    mode: "0644"
  notify: Reload httpd