deploiement/roles/cgit/tasks/main.yml
rick a9513167ca
fix bug when clone repo + rewrite
rewrite the installation of cgit to use git user.
2022-06-12 03:40:13 +02:00

136 lines
3.7 KiB
YAML

################################################################################
# installation de cgit et configuration de nginx et gitolite
#
# Copyright (C) 2022 rick G. <rick@gnous.eu>
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.
################################################################################
---
- name: update de la machine
apt:
update_cache: true
upgrade: yes
- name: installation des paquets nécessaires
apt:
name:
- libzip-dev
- libssl-dev
- zlib1g-dev
- python3-certbot-nginx
- fcgiwrap
- python3-zipp
- name: installation de pygments
ansible.builtin.pip:
name: pygments
- name: création utilisateur cgit
ansible.builtin.user:
name: "{{ git_user }}"
shell: "/bin/bash"
state: present
- name: mise en place de cgit
block:
- name: clonage de cgit
ansible.builtin.git:
dest: "{{ path_tmp_cgit }}"
repo: "https://git.zx2c4.com/cgit"
single_branch: yes
- name: configuration de la compilation de cgit
template:
src: "config-cgit.conf"
dest: "{{ path_tmp_cgit }}/cgit.conf"
mode: 0644
- name: compilation de cgit
community.general.make:
chdir: "{{ path_tmp_cgit }}"
- name: installation de cgit
community.general.make:
chdir: "{{ path_tmp_cgit }}"
target: install
- name: configuration de cgit
template:
src: "cgitrc"
dest: "{{ path_cgit }}"
mode: 0644
- name: clonage de gitolite
ansible.builtin.git:
dest: "{{ path_gitolite }}"
repo: "https://github.com/sitaramc/gitolite"
single_branch: yes
- name: création du dossier bin
file:
path: "{{ home_user }}/bin"
state: directory
- name: installation de gitolite
ansible.builtin.command:
cmd: "{{ path_gitolite }}/install -to {{ home_user }}/bin"
- name: upload de la clé SSH de l'admin
ansible.builtin.copy:
src: "../files/{{ admin_key }}"
dest: "/tmp/{{ admin_key }}"
- name: configuration du premier utilisateur
ansible.builtin.command:
cmd: "{{ home_user }}/bin/gitolite setup -pk /tmp/{{ admin_key }}"
- name: configuration des droits du dossier repositories
ansible.builtin.file:
path: "{{ home_user }}/repositories"
mode: 0705
state: directory
recurse: yes
- name: configuration des droits de la liste des repositories
ansible.builtin.file:
path: "{{ home_user }}/projects.list"
mode: 0705
- name: configuration des dépots
ansible.builtin.lineinfile:
path: "{{ home_user }}/.gitolite.rc"
regex: "UMASK"
line: "\tUMASK => 0072,"
become: yes
become_user: git
- name: configuration de Nginx
template:
src: "cgit-nginx"
dest: "/etc/nginx/sites-available/cgit.conf"
mode: 0644
- name: lien symbolique pour le site cgit
file:
src: /etc/nginx/sites-available/cgit.conf
dest: /etc/nginx/sites-enabled/cgit.conf
state: link
- name: démarrage par défaut de fcgiwrap
ansible.builtin.service:
name: fcgiwrap
enabled: yes
notify:
- restart fcgiwrap