ansible-gitea-management/tasks/forgejo/install.yml

115 lines
3 KiB
YAML

---
# Install forgejo
- name: "Ensure git is available"
ansible.builtin.package:
state: present
name: git
- name: "All forgejo steps from collection"
block:
- name: "Download the SHA file for forgejo"
ansible.builtin.uri:
url: "https://codeberg.org/forgejo/forgejo/releases/download/v{{ forgejo_version }}/forgejo-{{ forgejo_version }}-linux-{{ forgejo_arch }}.sha256"
return_content: true
register: forgejo_sha_content
- name: "Import var of SHA"
ansible.builtin.set_fact:
forgejo_sha_verif: "{{ forgejo_sha_content.content.split()[0] }}"
- name: "Get Forgejo binary"
ansible.builtin.get_url:
url: "https://codeberg.org/forgejo/forgejo/releases/download/v{{ forgejo_version }}/forgejo-{{ forgejo_version }}-linux-{{ forgejo_arch }}"
dest: "/usr/local/bin/forgejo-{{ forgejo_version }}-linux-{{ forgejo_arch }}"
checksum: "sha256:{{ forgejo_sha_verif }}"
mode: "0755"
register: forgejo_content
- name: "Symlink forgejo binary"
ansible.builtin.file:
src: "/usr/local/bin/forgejo-{{ forgejo_version }}-linux-{{ forgejo_arch }}"
dest: "/usr/local/bin/forgejo"
state: link
- name: "Setup user"
ansible.builtin.user:
name: "git"
state: present
system: true
- name: "Setup base directory structure and permissions"
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: "0750"
owner: "git"
group: "git"
loop: "{{ forgejo_directory_list }}"
- name: "Deploy systemd unit"
ansible.builtin.template:
src: "etc/systemd/system/forgejo.service.j2"
dest: "/etc/systemd/system/forgejo.service"
owner: root
group: root
mode: "0644"
notify:
- reload_systemd
- name: "Enable Forgejo"
ansible.builtin.systemd:
name: forgejo.service
enabled: true
state: started
daemon_reload: true
- name: "Install httpd"
ansible.builtin.dnf:
name: httpd
state: present
when:
- forgejo_web_install == "httpd"
- forgejo_web_config|bool
- name: "Start and enable httpd"
ansible.builtin.systemd:
name: httpd.service
enabled: true
state: started
when:
- forgejo_web_install == "httpd"
- forgejo_web_config|bool
- name: "Deploy httpd"
ansible.builtin.template:
src: etc/httpd/conf.d/forgejo.conf.j2
dest: /etc/httpd/conf.d/forgejo.conf
owner: root
group: root
mode: '0644'
when:
- forgejo_web_install == "httpd"
- forgejo_web_config|bool
notify:
- restart_httpd
# Setup CSS Themes
- name:
ansible.builtin.file:
path: "/var/lib/forgejo/custom/public/css"
owner: git
group: git
mode: '0755'
state: directory
recurse: true
# Setup Assets
- name:
ansible.builtin.file:
path: "/var/lib/forgejo/custom/public/assets/img"
owner: git
group: git
mode: '0755'
state: directory
recurse: true
...