aboutsummaryrefslogtreecommitdiffstats
path: root/roles/obsd_git/tasks/main.yml
blob: bf6abc8b85f7d508fe41d162ef434930e76391c5 (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
101
- name: Install git
  community.general.openbsd_pkg:
    name: "{{ obsd_git_packages }}"
    state: present

- name: Create git user
  ansible.builtin.user:
    name: "{{ obsd_git_user }}"
    home: "{{ obsd_git_home }}"
    create_home: false
    shell: /usr/local/bin/git-shell
    system: true

- name: Create git home directory
  ansible.builtin.file:
    path: "{{ obsd_git_home }}"
    state: directory
    owner: "{{ obsd_git_user }}"
    group: "{{ obsd_git_user }}"
    mode: "0755"

- name: Create public git repository directory
  ansible.builtin.file:
    path: "{{ obsd_git_home }}/public"
    state: directory
    owner: "{{ obsd_git_user }}"
    group: "{{ obsd_git_user }}"
    mode: "0755"

- name: Create private git repository directory
  ansible.builtin.file:
    path: "{{ obsd_git_home }}/private"
    state: directory
    owner: "{{ obsd_git_user }}"
    group: "{{ obsd_git_user }}"
    mode: "0750"

- name: Silence message of the day for git user
  ansible.builtin.file:
    path: "{{ obsd_git_home }}/.hushlogin"
    state: touch
    owner: "{{ obsd_git_user }}"
    group: "{{ obsd_git_user }}"
    mode: "0644"
    modification_time: preserve

- name: Create .ssh directory
  ansible.builtin.file:
    path: "{{ obsd_git_home }}/.ssh"
    state: directory
    owner: "{{ obsd_git_user }}"
    group: "{{ obsd_git_user }}"
    mode: "0700"

- name: Deploy authorized_keys
  ansible.builtin.copy:
    content: "{{ obsd_git_authorized_keys | join('\n') }}\n"
    dest: "{{ obsd_git_home }}/.ssh/authorized_keys"
    owner: "{{ obsd_git_user }}"
    group: "{{ obsd_git_user }}"
    mode: "0600"

- name: Create git-shell-commands directory
  ansible.builtin.file:
    path: "{{ obsd_git_home }}/git-shell-commands"
    state: directory
    owner: "{{ obsd_git_user }}"
    group: "{{ obsd_git_user }}"
    mode: "0755"

- name: Deploy git-shell create-repo helper script
  ansible.builtin.template:
    src: git-shell-commands/create
    dest: "{{ obsd_git_home }}/git-shell-commands/create"
    owner: "{{ obsd_git_user }}"
    group: "{{ obsd_git_user }}"
    mode: "0755"

- name: Create shared hooks directory
  ansible.builtin.file:
    path: "{{ obsd_git_hooks_dir }}"
    state: directory
    owner: "{{ obsd_git_user }}"
    group: "{{ obsd_git_user }}"
    mode: "0755"

- name: Deploy post-receive hook
  ansible.builtin.template:
    src: hooks/post-receive
    dest: "{{ obsd_git_hooks_dir }}/post-receive"
    owner: "{{ obsd_git_user }}"
    group: "{{ obsd_git_user }}"
    mode: "0755"

- name: Deploy git user gitconfig
  ansible.builtin.template:
    src: gitconfig
    dest: "{{ obsd_git_home }}/.gitconfig"
    owner: "{{ obsd_git_user }}"
    group: "{{ obsd_git_user }}"
    mode: "0644"