From 427667ad3fb3dcc914c8fedc593f734533984451 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 14 Feb 2023 13:56:28 +0100 Subject: [PATCH] add site-formation --- seed/README.md | 4 ++ seed/forgejo-formation/README.md | 10 ++- .../dictionaries/32_forgejo.yml | 26 ++++++++ .../patches/forgejo.service.patch | 3 +- seed/site-formation/README.md | 52 ++++++++++++++++ seed/site-formation/applicationservice.yml | 5 ++ seed/site-formation/dictionaries/23_site.yml | 61 +++++++++++++++++++ .../manual/image/preinstall/site.sh | 1 + seed/site-formation/templates/nginx.service | 2 + seed/site-formation/templates/site_update | 17 ++++++ .../templates/site_update.service | 10 +++ .../templates/site_update.timer | 9 +++ 12 files changed, 196 insertions(+), 4 deletions(-) create mode 100644 seed/site-formation/README.md create mode 100644 seed/site-formation/applicationservice.yml create mode 100644 seed/site-formation/dictionaries/23_site.yml create mode 100644 seed/site-formation/manual/image/preinstall/site.sh create mode 100644 seed/site-formation/templates/nginx.service create mode 100644 seed/site-formation/templates/site_update create mode 100644 seed/site-formation/templates/site_update.service create mode 100644 seed/site-formation/templates/site_update.timer diff --git a/seed/README.md b/seed/README.md index cc9158c..fa85d70 100644 --- a/seed/README.md +++ b/seed/README.md @@ -1,6 +1,10 @@ # Application services - [forgejo-formation](forgejo-formation/README.md): Formation in Forgejo +- [site-formation](site-formation/README.md): Diffusion du contenu du dépôt git # Providers and suppliers +- Site: + - Provider: [forgejo-formation](forgejo-formation/README.md) + - Supplier: [site-formation](site-formation/README.md) diff --git a/seed/forgejo-formation/README.md b/seed/forgejo-formation/README.md index 105c31a..089e8da 100644 --- a/seed/forgejo-formation/README.md +++ b/seed/forgejo-formation/README.md @@ -1,12 +1,10 @@ --- -forgejo: none +gitea: none include_toc: true --- # forgejo-formation -[All applications services for this dataset.](../README.md) - ## Description Formation in Forgejo. @@ -49,3 +47,9 @@ Formation in Forgejo. - [+]: variable is multiple - **bold**: variable is mandatory + +## Supplier + +[site-formation](../site-formation/README.md) + +[All applications services for this dataset.](../README.md) diff --git a/seed/forgejo-formation/dictionaries/32_forgejo.yml b/seed/forgejo-formation/dictionaries/32_forgejo.yml index ae69f21..f8ab6b8 100644 --- a/seed/forgejo-formation/dictionaries/32_forgejo.yml +++ b/seed/forgejo-formation/dictionaries/32_forgejo.yml @@ -23,6 +23,25 @@ variables: type: password hidden: true mandatory: true + - name: forgejo_site + hidden: true + provider: Site + mandatory: true + - name: forgejo_site_user + type: unix_user + hidden: true + mandatory: true + provider: Site:username + - name: forgejo_site_email + type: mail + hidden: true + mandatory: true + provider: Site:email + - name: forgejo_site_password + type: password + hidden: true + mandatory: true + provider: Site:password constraints: - fill: - name: get_password @@ -42,3 +61,10 @@ constraints: text: hide_secret target: - text: forgejo_password +- check: + - name: valid_not_equal + param: + - type: variable + text: forgejo_email + target: + - text: forgejo_site_email diff --git a/seed/forgejo-formation/patches/forgejo.service.patch b/seed/forgejo-formation/patches/forgejo.service.patch index e0620a3..0d4c042 100644 --- a/seed/forgejo-formation/patches/forgejo.service.patch +++ b/seed/forgejo-formation/patches/forgejo.service.patch @@ -1,6 +1,6 @@ --- ../../../dataset/seed/forgejo/templates/forgejo.service 2023-01-03 11:30:06.865085785 +0100 +++ modif/forgejo.service 2023-02-14 10:13:27.985282958 +0100 -@@ -20,18 +20,7 @@ +@@ -20,18 +20,8 @@ Group=forgejo WorkingDirectory=/srv/forgejo/lib/ ExecStart=/usr/bin/forgejo web --config /etc/forgejo/app.ini @@ -17,6 +17,7 @@ -sleep 2;%slurp -echo "CONFIGURATION DONE"' +ExecStartPre=-/bin/bash -c "/usr/bin/forgejo admin user create --username %%forgejo_user --password %%forgejo_password --email %%forgejo_email --admin -c /etc/forgejo/app.ini" ++ExecStartPre=-/bin/bash -c "/usr/bin/forgejo admin user create --username %%forgejo_site_user --password %%forgejo_site_password --email %%forgejo_site_email --must-change-password=false -c /etc/forgejo/app.ini" Restart=always Environment=GITEA_WORK_DIR=/srv/forgejo/lib diff --git a/seed/site-formation/README.md b/seed/site-formation/README.md new file mode 100644 index 0000000..737c794 --- /dev/null +++ b/seed/site-formation/README.md @@ -0,0 +1,52 @@ +--- +gitea: none +include_toc: true +--- + +# site-formation + +## Description + +Diffusion du contenu du dépôt git. + +[For more informations](https://nginx.org/) + +## Dependances + +- [nginx-static (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/nginx-static/README.md) + - [nginx-https (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/nginx-https/README.md) + - [nginx-common (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/nginx-common/README.md) + - [reverse-proxy-client (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/reverse-proxy-client/README.md) + - [base-fedora-37 (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/base-fedora-37/README.md) + - [base-fedora (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/base-fedora/README.md) + - [systemd (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/systemd/README.md) + - [base-machine (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/base-machine/README.md) + - [base (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/base/README.md) + - [dns-local (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/dns-local/README.md) + - [pki-tls (in external dataset)](https://forge.cloud.silique.fr/gnunux/dataset/src/branch/main/seed/pki-tls/README.md) + +## Variables + +### Général (*general*) + +#### nginx (*general.nginx*) + +| Description | Values | +|----------------------------------------------|----------------------| +| *[**nginx_root**](dictionaries/23_site.yml)* | /srv/git/site/static | + +#### forgejo (*general.forgejo*) + +| Description | Type | Supplier | +|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------|------------| +| Email de l'utilisateur Site dans Forgejo (*[site_user_mail](dictionaries/23_site.yml)*) | [mail](https://forge.cloud.silique.fr/risotto/rougail/src/branch/main/doc/variable/README.md#le-type-de-la-variable) | Site:email | + + +- [+]: variable is multiple +- **bold**: variable is mandatory + +## Provider + +[forgejo-formation](../forgejo-formation/README.md) + +[All applications services for this dataset.](../README.md) diff --git a/seed/site-formation/applicationservice.yml b/seed/site-formation/applicationservice.yml new file mode 100644 index 0000000..3755713 --- /dev/null +++ b/seed/site-formation/applicationservice.yml @@ -0,0 +1,5 @@ +format: '0.1' +description: Diffusion du contenu du dépôt git +website: https://nginx.org/ +depends: + - nginx-static diff --git a/seed/site-formation/dictionaries/23_site.yml b/seed/site-formation/dictionaries/23_site.yml new file mode 100644 index 0000000..c02ed7b --- /dev/null +++ b/seed/site-formation/dictionaries/23_site.yml @@ -0,0 +1,61 @@ +version: '0.10' +services: +- service: + - name: nginx + override: null + - name: site_update + engine: none + file: + - text: /sbin/site_update + mode: 755 + - name: site_update + type: timer + engine: none +variables: +- family: + - name: nginx + variables: + - variable: + - name: nginx_root + redefine: true + value: + - text: /srv/git/site/static + - name: forgejo + variables: + - variable: + - name: site_domain_name + hidden: true + supplier: Site + - name: site_user_name + type: unix_user + hidden: true + supplier: Site:username + value: + - text: site + - name: site_user_mail + type: mail + description: Email de l'utilisateur Site dans Forgejo + supplier: Site:email + - name: site_user_password + type: password + hidden: true + supplier: Site:password +constraints: +- fill: + - name: get_password + param: + - type: variable + name: server_name + text: domain_name_eth0 + - type: variable + name: username + text: site_user_name + - name: description + text: site + - name: type + text: cleartext + - name: hide + type: variable + text: hide_secret + target: + - text: site_user_password diff --git a/seed/site-formation/manual/image/preinstall/site.sh b/seed/site-formation/manual/image/preinstall/site.sh new file mode 100644 index 0000000..813dcda --- /dev/null +++ b/seed/site-formation/manual/image/preinstall/site.sh @@ -0,0 +1 @@ +PKG="$PKG git-core" diff --git a/seed/site-formation/templates/nginx.service b/seed/site-formation/templates/nginx.service new file mode 100644 index 0000000..ba9004b --- /dev/null +++ b/seed/site-formation/templates/nginx.service @@ -0,0 +1,2 @@ +[Unit] +After=site_clone.target diff --git a/seed/site-formation/templates/site_update b/seed/site-formation/templates/site_update new file mode 100644 index 0000000..47c8590 --- /dev/null +++ b/seed/site-formation/templates/site_update @@ -0,0 +1,17 @@ +%echo "#!/bin/bash -e" + +%from os.path import dirname + +GIT_DIR=%%dirname(%%dirname(%%nginx_root)) +REPO_DIR=%%dirname(%%nginx_root) + +if [ ! -d $GIT_SITE/.git ]; then + if [ -d %%nginx_root ]; then + rm -rf %%nginx_root + fi + cd $GIT_DIR + git clone https://%%site_user_name:%%site_user_password@%%site_domain_name:3000/pedago/site.git +fi +cd $REPO_DIR +git pull +exit 0 diff --git a/seed/site-formation/templates/site_update.service b/seed/site-formation/templates/site_update.service new file mode 100644 index 0000000..23e2857 --- /dev/null +++ b/seed/site-formation/templates/site_update.service @@ -0,0 +1,10 @@ +[Unit] +Description=Update site files +After=risotto.target + +[Service] +Type=oneshot +ExecStart=/usr/local/lib/sbin/site_update + +[Install] +WantedBy=multi-user.target diff --git a/seed/site-formation/templates/site_update.timer b/seed/site-formation/templates/site_update.timer new file mode 100644 index 0000000..d638709 --- /dev/null +++ b/seed/site-formation/templates/site_update.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Run site updater + +[Timer] +OnUnitActiveSec=1h +Unit=site_update.service + +[Install] +WantedBy=timers.target