summaryrefslogtreecommitdiffstats
path: root/roles/cgit/tasks/main.yml
blob: 7828042abbe516c436f28fbeab3c720ea7a537cd (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
---
- name: "Install packages"
  become: true
  ansible.builtin.package:
    name:
      - cgit
      - lighttpd
      - openssh
    state: present

- name: "Create git group"
  become: true
  ansible.builtin.group:
    name: "{{ cgit_ssh_user }}"
    system: true

- name: "Create git user"
  become: true
  ansible.builtin.user:
    name: "{{ cgit_ssh_user }}"
    group: "{{ cgit_ssh_user }}"
    shell: "/usr/bin/git-shell"
    home: "{{ cgit_repos_dir }}"
    create_home: true
    system: true
    password: "*"

- name: "Set default branch name for new repos"
  become: true
  community.general.git_config:
    name: init.defaultBranch
    scope: system
    value: main

- name: "Create git user .ssh directory"
  become: true
  ansible.builtin.file:
    path: "{{ cgit_repos_dir }}/.ssh"
    state: directory
    owner: "{{ cgit_ssh_user }}"
    group: "{{ cgit_ssh_user }}"
    mode: "0700"

- name: "Deploy authorized_keys"
  become: true
  ansible.posix.authorized_key:
    user: "{{ cgit_ssh_user }}"
    key: "{{ item }}"
    state: present
  loop: "{{ user_public_keys }}"

- name: "Create repos directory"
  become: true
  ansible.builtin.file:
    path: "{{ cgit_repos_dir }}"
    state: directory
    owner: "{{ cgit_ssh_user }}"
    group: "{{ cgit_ssh_user }}"
    mode: "2755"

- name: "Deploy cgitrc"
  become: true
  ansible.builtin.template:
    src: "cgitrc.j2"
    dest: "/etc/cgitrc"
    owner: "root"
    group: "root"
    mode: "0644"

- name: "Deploy lighttpd config"
  become: true
  ansible.builtin.template:
    src: "cgit.lighttpd.conf.j2"
    dest: "/etc/lighttpd/lighttpd.conf"
    owner: "root"
    group: "root"
    mode: "0644"
  notify: "Restart lighttpd"

- name: "Enable and start services"
  become: true
  ansible.builtin.service:
    name: "{{ item }}"
    enabled: true
    state: started
  loop:
    - lighttpd
    - sshd