aboutsummaryrefslogtreecommitdiffstats
path: root/roles/cgit/tasks/main.yml
blob: 28abc9ca7f5d2b9ab31e085b4e3fc6718c16e0f9 (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

# cgit ~~ roles/cgit/tasks/main.yml
# cgit web interface

---

- name: ensure cgit is installed
  package:
    name: cgit
    state: present

- name: generate cgit configuration file
  template:
    src: cgitrc.j2
    dest: /var/www/conf/cgitrc
    owner: "{{ user_root }}"
    group: "{{ group_root }}"
    mode: 0644

- name: generate cgit configuration for httpd
  template:
    src: cgit.httpd.conf.j2
    dest: /etc/httpd.d/cgit.conf
    owner: "{{ user_root }}"
    group: "{{ group_root }}"
    mode: 0644

- name: copy utility in httpd chroot
  copy:
    src: "/bin/{{ item }}"
    dest: /var/www/bin
    remote_src: true
  loop:
    - "sh"
    - "cat"

- name: copy about-filter generator
  copy:
    src: about-filter.sh
    dest: /var/www/bin/about-filter.sh
    owner: "{{ user_root }}"
    group: "{{ group_root }}"
    mode: 0755

- name: unmount potential existing filesystem in target directory
  shell: "umount /var/www/{{ cgit_git_dir_chroot }}"
  register: result
  failed_when: result.rc != 0 and "not currently mounted" not in result.stderr

- name: ensure cgit web directory exists
  file:
    path: /var/www/{{ cgit_git_dir_chroot }}
    owner: www
    group: daemon
    mode: 0644
    state: directory

- name: enable shared git directory in /etc/exports
  lineinfile:
    path: /etc/exports
    regexp: "^{{ cgit_git_dir }}"
    line: "{{ cgit_git_dir }} -mapall=root -alldirs -network=127.0.0.1 -mask=255.255.255.255 -ro"
    owner: "{{ user_root }}"
    group: "{{ group_root }}"
    mode: 0644
    create: true

- name: enable shared git directory in /etc/exports
  lineinfile:
    path: /etc/fstab
    regexp: "^localhost:{{ cgit_git_dir }}"
    line: "localhost:{{ cgit_git_dir }} /var/www/{{ cgit_git_dir_chroot }} nfs rw,nodev,nosuid,soft,intr 0 0"

- name: start and enable share directory
  service:
    name: "{{ item }}"
    state: restarted
    enabled: true
  loop:
    - "portmap"
    - "nfsd"

- name: start and enable mountd
  shell: |
    rcctl enable mountd
    pkill -9 mountd
    rcctl start mountd

- name: ensure nfs volume is mounted
  shell: mount -A
  register: result
  failed_when: result.rc != 0 and "Device busy" is not in result.stderr

- name: start and enable slowcgi service
  service:
    name: slowcgi
    state: restarted
    enabled: true
remember that computers suck.