[INFO] Créer le dépôt #1

Merged
pulsar merged 1 commits from alpha into master 2023-07-06 17:09:27 +00:00
7 changed files with 164 additions and 4 deletions

View File

@ -1,3 +1,40 @@
# role_modele
# role_gitea
Modèle
Rôle de déploiement de gitea.
## Fonctionnement
Ce rôle nécessite la création d'un utilisateur dédié. La création de cet utilisateur passe par un rôle défini dans `meta/main.yml`.<br>
La configuration de logrotate est poussée en écrasant le fichier `/etc/logrotate.d/gitea`.
## Variables
### gitea_version_file
URL permettant de déterminer quelle est la dernière version.
<span style="text-decoration: underline">Valeur par défaut:</span> `https://dl.gitea.io/gitea/version.json`
### gitea_version
Afin d'installer une version spécifique, définir cette variable.
<span style="text-decoration: underline">Valeur par défaut:</span> aucune
### gitea_architecture
Architecture de la machine où est effectué le déploiement.
<span style="text-decoration: underline">Valeur par défaut:</span> `arm64`
### gitea_install_path
Emplacement d'installation du binaire.
<span style="text-decoration: underline">Valeur par défaut:</span> `/opt/gitea`
### gitea_logs_path
Emplacement où seront stockés les journaux.
<span style="text-decoration: underline">Valeur par défaut:</span> `/var/log/gitea`

10
defaults/main.yml Executable file
View File

@ -0,0 +1,10 @@
---
# vars file for gitea
gitea_version_file: https://dl.gitea.io/gitea/version.json
gitea_version: ""
gitea_architecture: arm64
gitea_install_path: /opt/gitea
gitea_logs_path: /var/log/gitea

10
handlers/main.yml Executable file
View File

@ -0,0 +1,10 @@
---
# handlers file for gitea
- name: Redémarrer gitea.service
ansible.builtin.systemd:
enabled: true
daemon_reload: true
state: restarted
name: gitea.service
become: true

View File

@ -1,7 +1,7 @@
galaxy_info:
namespace: ykn
author: pulsar89.5
description: Rôle modèle
description: Rôle de déploiement de gitea
license: GPL-3.0-or-later
@ -12,4 +12,15 @@ galaxy_info:
versions:
- all
dependencies: []
dependencies:
- role: users
vars:
users_role_gitea:
- name: gitea
comment: Dedicated GiTea user
update_password: on_create
password_lock: true
shell: /bin/bash
extras:
authorized_keys:
- command="/opt/gitea/gitea.bin --config='/opt/gitea/custom/conf/app.ini' serv key-1",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty

57
tasks/main.yml Executable file
View File

@ -0,0 +1,57 @@
---
# tasks file for gitea
- name: Créer les dossiers
ansible.builtin.file:
owner: gitea
group: gitea
mode: u=rwx,g=rx,o=rx
state: directory
path: "{{ item }}"
become: true
loop:
- "{{ gitea_install_path }}"
- "{{ gitea_logs_path }}"
- name: Récupérer le contenu du fichier de version
ansible.builtin.uri:
url: "{{ gitea_version_file }}"
return_content: true
follow_redirects: all
when: not gitea_version | length > 0
register: version_file
- name: Extraire la dernière version
ansible.builtin.set_fact:
gitea_version: "{{ (version_file.content | from_json).latest.version }}"
when: not gitea_version | length > 0
- name: Télécharger le binaire
ansible.builtin.get_url:
owner: gitea
group: gitea
mode: u=rwx,g=,o=
checksum: "sha256:https://dl.gitea.io/gitea/{{ gitea_version }}/gitea-{{ gitea_version }}-linux-{{ gitea_architecture }}.sha256"
url: https://dl.gitea.io/gitea/{{ gitea_version }}/gitea-{{ gitea_version }}-linux-{{ gitea_architecture }}
dest: "{{ gitea_install_path }}/gitea.bin"
become: true
notify: Redémarrer gitea.service
- name: Déployer le service
become: true
ansible.builtin.template:
owner: root
group: root
mode: u=rw,g=r,o=r
src: gitea.service.j2
dest: /etc/systemd/system/gitea.service
notify: Redémarrer gitea.service
- name: Déployer la configuration logrotate
become: true
ansible.builtin.template:
owner: root
group: root
mode: u=rw,g=r,o=r
src: logrotate.conf.j2
dest: /etc/logrotate.d/gitea

24
templates/gitea.service.j2 Executable file
View File

@ -0,0 +1,24 @@
# {{ ansible_managed }}
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
[Service]
RestartSec=2s
Type=simple
User=gitea
Group=gitea
WorkingDirectory={{ gitea_install_path }}
ExecStart={{ gitea_install_path }}/gitea.bin web
Restart=always
Environment="USER=gitea"
Environment="HOME={{ gitea_install_path }}"
Environment="GITEA_WORK_DIR={{ gitea_install_path }}"
[Install]
WantedBy=multi-user.target

11
templates/logrotate.conf.j2 Executable file
View File

@ -0,0 +1,11 @@
# {{ ansible_managed }}
{{ gitea_logs_path }}/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 0640 gitea gitea
}