diff --git a/roles/site/files/install-packages.el b/roles/site/files/install-packages.el new file mode 100644 index 0000000..7fae66d --- /dev/null +++ b/roles/site/files/install-packages.el @@ -0,0 +1,7 @@ +(require 'package) +(add-to-list 'package-archives + '("melpa" . "https://stable.melpa.org/packages/") t) +(package-initialize) +(package-initialize) +(package-refresh-contents) +(package-install 'htmlize) diff --git a/roles/site/tasks/main.yml b/roles/site/tasks/main.yml new file mode 100644 index 0000000..4bf21cd --- /dev/null +++ b/roles/site/tasks/main.yml @@ -0,0 +1,74 @@ +################################################################################ +# installation de cgit et configuration de nginx et gitolite +# +# Copyright (C) 2022 rick G. +# +# 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 . +################################################################################ + +--- +- name: update de la machine + apt: + update_cache: true + upgrade: yes + +- name: installation des paquets nécessaires + apt: + name: + - emacs + +- name: installation de htmlize + block: + - name: copie du script d'installation + ansible.builtin.copy: + src: "../files/install-packages.el" + dest: "/tmp/init.el" + + - name: installation de htmlize + ansible.builtin.command: + cmd: "emacs -u {{ user }} --script /tmp/init.el" + ignore_errors: yes + +- name: clonage du site + ansible.builtin.git: + dest: "{{ path_clone }}" + repo: "{{ git }}" + single_branch: yes + +- name: compilation du site + ansible.builtin.command: + cmd: "{{ path_clone }}/generate.sh" + chdir: "{{ path_clone }}" + +- name: génération du lien symbolique + file: + src: "{{ path_clone }}/www" + path: "{{ path_site }}" + state: link + +- name: configuration de nginx + template: + src: "site-nginx" + dest: "{{ ava }}/gyiwr.conf" + mode: 0644 + +- name: suppression de la configuration par défaut + ansible.builtin.file: + path: "{{ ena }}/default" + state: absent + +- name: lien symbolique pour le site + file: + src: "{{ ava }}/gyiwr.conf" + dest: "{{ ena }}/gyiwr.conf" + state: link diff --git a/roles/site/templates/site-nginx b/roles/site/templates/site-nginx new file mode 100644 index 0000000..8527949 --- /dev/null +++ b/roles/site/templates/site-nginx @@ -0,0 +1,13 @@ +server { + server_name {{ site }}; + listen 80; + listen [::]:80; + + root {{ path_site }}; + + index index.html index.htm index.nginx-debian.html; + + location / { + try_files $uri $uri/ =404; + } +} diff --git a/vars/principal.yml b/vars/principal.yml new file mode 100644 index 0000000..3d76486 --- /dev/null +++ b/vars/principal.yml @@ -0,0 +1,4 @@ +--- +path_site: "/var/www/gyiwr" +git: "https://git.gyiwr.tf/gyiwr" +path_clone: "/home/ubuntu/gyiwr" diff --git a/vars/sites.yml b/vars/sites.yml index a6d3807..5bd43cf 100644 --- a/vars/sites.yml +++ b/vars/sites.yml @@ -1,3 +1,7 @@ --- site: "" cgit_site: "" + +user: "ubuntu" +ava: "/etc/nginx/sites-available" +ena: "/etc/nginx/sites-enabled"