aboutsummaryrefslogtreecommitdiff
path: root/roles/gitea/tasks/main.yml
blob: 36e5f439897381505506d099005ebc0af7ec7bf2 (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
---
- name: Install packages
  apt:
    name:
      - git
  become: yes

- name: Create User
  user:
    name: git
    home: /home/git
    shell: /bin/bash
    system: yes
    state: present
  become: yes

- name: Folder structure
  file:
    path: '{{ item }}'
    owner: git
    group: git
    mode: '750'
    state: directory
  become: yes
  loop:
    - /var/lib/gitea/
    - /var/lib/gitea/custom
    - /var/lib/gitea/data
    - /var/lib/gitea/log

- name: Config folder
  file:
    path: /etc/gitea
    owner: root
    group: git
    mode: '750'
    state: directory
  become: yes

- name: pull sha256sum
  uri:
    url: 'https://dl.gitea.io/gitea/{{ gitea.version.ver }}/gitea-{{ gitea.version.ver }}-linux-amd64.sha256'
    method: GET
    return_content: yes
  register: gitea_sha256_raw

- name: set sha256sum
  set_fact:
    gitea_sha256: '{{ (gitea_sha256_raw.content | split(" "))[0] }}'
    cacheable: false

- name: Check for update
  stat:
    path: /usr/local/bin/gitea
    checksum_algorithm: sha256
  register: gitea_bin_stat
  ignore_errors: yes

- name: perform update
  include: update.yml
  when:
    - (not gitea_bin_stat.stat.exists) or (gitea_bin_stat.stat.checksum != gitea_sha256)

- name: Check if initial setup is needed
  include_tasks: secrets.yml

- name: Read secret Key
  slurp:
    src: /etc/gitea/secret_key
  become: yes
  register: sec_key

- name: Read secret Key
  slurp:
    src: /etc/gitea/internal_token
  become: yes
  register: int_tok

- name: Install gitea config file
  template:
    src: app.ini.j2
    dest: /etc/gitea/app.ini
    owner: root
    group: git
    mode: '640'
  become: yes
  notify:
    - Handle systemd

- name: Check for changed cert
  command: /bin/true
  when:
    - cert_changed
  notify:
    - Handle systemd

- name: Install gitea unit file
  copy:
    src: gitea.service
    dest: /etc/systemd/system/gitea.service
  become: yes
  notify:
    - Handle systemd

- name: Flush handlers
  meta: flush_handlers

- name: Wait 10s for gitea to start
  wait_for:
    timeout: 10
  delegate_to: localhost
# This only install base configuration. Group settings have to be set manually in gitea...
- name: Install LDAP
  include_tasks: ldap.yml
  when: gitea.ldap.enable