[INFO] Créer le dépôt
This commit is contained in:
parent
da781312bc
commit
eea8a67515
41
README.md
41
README.md
@ -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
10
defaults/main.yml
Executable 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
10
handlers/main.yml
Executable 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
|
@ -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
57
tasks/main.yml
Executable 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
24
templates/gitea.service.j2
Executable 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
11
templates/logrotate.conf.j2
Executable file
@ -0,0 +1,11 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
{{ gitea_logs_path }}/*.log {
|
||||
daily
|
||||
missingok
|
||||
rotate 14
|
||||
compress
|
||||
delaycompress
|
||||
notifempty
|
||||
create 0640 gitea gitea
|
||||
}
|
Loading…
Reference in New Issue
Block a user