From 0d53ae97681965c332d77eab9b0defd2fa226333 Mon Sep 17 00:00:00 2001 From: samuel Date: Fri, 8 May 2020 12:10:48 +0200 Subject: [PATCH 1/2] revison --- sami/my-cdist/.cdist/sample | 1 - .../.cdist/type/__my_computer/manifest | 25 +++++++++++ .../singleton} | 0 .../__sample_bottle_hosting/gencode-remote | 1 - .../type/__sample_bottle_hosting/manifest | 43 ------------------- .../parameter/required | 4 -- .../.cdist/type/__sample_nginx/manifest | 13 ------ .../gencode-remote | 1 - .../manifest | 25 ----------- .../parameter/required | 1 - 10 files changed, 25 insertions(+), 89 deletions(-) delete mode 100644 sami/my-cdist/.cdist/sample create mode 100755 sami/my-cdist/.cdist/type/__my_computer/manifest rename sami/my-cdist/.cdist/type/{__sample_nginx/gencode-remote => __my_computer/singleton} (100%) delete mode 100644 sami/my-cdist/.cdist/type/__sample_bottle_hosting/gencode-remote delete mode 100644 sami/my-cdist/.cdist/type/__sample_bottle_hosting/manifest delete mode 100644 sami/my-cdist/.cdist/type/__sample_bottle_hosting/parameter/required delete mode 100644 sami/my-cdist/.cdist/type/__sample_nginx/manifest delete mode 100644 sami/my-cdist/.cdist/type/__sample_nginx_http_letsencrypt_and_ssl_redirect/gencode-remote delete mode 100644 sami/my-cdist/.cdist/type/__sample_nginx_http_letsencrypt_and_ssl_redirect/manifest delete mode 100644 sami/my-cdist/.cdist/type/__sample_nginx_http_letsencrypt_and_ssl_redirect/parameter/required diff --git a/sami/my-cdist/.cdist/sample b/sami/my-cdist/.cdist/sample deleted file mode 100644 index c28e3ac..0000000 --- a/sami/my-cdist/.cdist/sample +++ /dev/null @@ -1 +0,0 @@ -__sample_bottle_hosting --projectname sample --user app --domain $__target_host sample diff --git a/sami/my-cdist/.cdist/type/__my_computer/manifest b/sami/my-cdist/.cdist/type/__my_computer/manifest new file mode 100755 index 0000000..07320cd --- /dev/null +++ b/sami/my-cdist/.cdist/type/__my_computer/manifest @@ -0,0 +1,25 @@ +#!/bin/sh -e +# +# 2012 Nico Schottelius (nico-cdist at schottelius.org) +# +# This file is part of cdist. +# +# cdist 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. +# +# cdist 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 cdist. If not, see . +# +# +# Ensure sipcalc is present +# + +__package sipcalc --state present + diff --git a/sami/my-cdist/.cdist/type/__sample_nginx/gencode-remote b/sami/my-cdist/.cdist/type/__my_computer/singleton similarity index 100% rename from sami/my-cdist/.cdist/type/__sample_nginx/gencode-remote rename to sami/my-cdist/.cdist/type/__my_computer/singleton diff --git a/sami/my-cdist/.cdist/type/__sample_bottle_hosting/gencode-remote b/sami/my-cdist/.cdist/type/__sample_bottle_hosting/gencode-remote deleted file mode 100644 index a4cceb5..0000000 --- a/sami/my-cdist/.cdist/type/__sample_bottle_hosting/gencode-remote +++ /dev/null @@ -1 +0,0 @@ -echo "service nginx restart" diff --git a/sami/my-cdist/.cdist/type/__sample_bottle_hosting/manifest b/sami/my-cdist/.cdist/type/__sample_bottle_hosting/manifest deleted file mode 100644 index d0b9ecd..0000000 --- a/sami/my-cdist/.cdist/type/__sample_bottle_hosting/manifest +++ /dev/null @@ -1,43 +0,0 @@ -os=$(cat "$__global/explorer/os") - -case "$os" in - ubuntu) - : - ;; - *) - echo "OS $os currently not supported" >&2 - exit 1 - ;; -esac - - -user="$(cat "$__object/parameter/user")" -home="/home/$user" -apphome="$home/app" - -# create user -__user "$user" --home "$home" --shell /bin/bash -# create user home dir -require="__user/$user" __directory "$home" \ - --owner "$user" --group "$user" --mode 0755 -# create app home dir -require="__user/$user __directory/$home" __directory "$apphome" \ - --state present --owner "$user" --group "$user" --mode 0755 - - -# define packages that need to be installed -packages_to_install="nginx uwsgi-plugin-python3 python3-dev python3-pip postgresql postgresql-contrib libpq-dev python3-venv uwsgi python3-psycopg2" - -# update package index -__apt_update_index -# install packages -for package in $packages_to_install - do require="__apt_update_index" __package $package --state=present -done - -# install pip3 packages -for package in bottle bottle-pgsql; do - __package_pip --pip pip3 $package -done - - diff --git a/sami/my-cdist/.cdist/type/__sample_bottle_hosting/parameter/required b/sami/my-cdist/.cdist/type/__sample_bottle_hosting/parameter/required deleted file mode 100644 index 719e766..0000000 --- a/sami/my-cdist/.cdist/type/__sample_bottle_hosting/parameter/required +++ /dev/null @@ -1,4 +0,0 @@ -# required parameter -projectname -user -domain diff --git a/sami/my-cdist/.cdist/type/__sample_nginx/manifest b/sami/my-cdist/.cdist/type/__sample_nginx/manifest deleted file mode 100644 index 14a9ac9..0000000 --- a/sami/my-cdist/.cdist/type/__sample_nginx/manifest +++ /dev/null @@ -1,13 +0,0 @@ -domain="$(cat "$__object/parameter/domain")" -webroot="/var/www/html" -__sample_nginx_http_letsencrypt_and_ssl_redirect "$domain" --webroot "$webroot" - - -# create SSL cert -require="__package/nginx __sample_nginx_http_letsencrypt_and_ssl_redirect/$domain" \ - __letsencrypt_cert --admin-email samuel.hailu@ungleich.ch \ - --webroot "$webroot" \ - --automatic-renewal \ - --renew-hook "service nginx reload" \ - --domain "$domain" \ - "$domain" diff --git a/sami/my-cdist/.cdist/type/__sample_nginx_http_letsencrypt_and_ssl_redirect/gencode-remote b/sami/my-cdist/.cdist/type/__sample_nginx_http_letsencrypt_and_ssl_redirect/gencode-remote deleted file mode 100644 index 9adb30b..0000000 --- a/sami/my-cdist/.cdist/type/__sample_nginx_http_letsencrypt_and_ssl_redirect/gencode-remote +++ /dev/null @@ -1 +0,0 @@ -echo "service nginx reload" diff --git a/sami/my-cdist/.cdist/type/__sample_nginx_http_letsencrypt_and_ssl_redirect/manifest b/sami/my-cdist/.cdist/type/__sample_nginx_http_letsencrypt_and_ssl_redirect/manifest deleted file mode 100644 index 38ca444..0000000 --- a/sami/my-cdist/.cdist/type/__sample_nginx_http_letsencrypt_and_ssl_redirect/manifest +++ /dev/null @@ -1,25 +0,0 @@ -domain="$__object_id" -webroot="$(cat "$__object/parameter/webroot")" -# make sure we have nginx package -__package nginx -# setup Let's Encrypt HTTP acme challenge, redirect HTTP to HTTPS -require="__package/nginx" __file "/etc/nginx/sites-enabled/http-$domain" \ - --source - --mode 0644 << EOF -server { - listen *:80; - listen [::]:80; - - server_name $domain; - - # Let's Encrypt - location /.well-known/acme-challenge/ { - root $webroot; - } - - # Everything else -> SSL - location / { - return 301 https://\$host\$request_uri; - } -} - -EOF diff --git a/sami/my-cdist/.cdist/type/__sample_nginx_http_letsencrypt_and_ssl_redirect/parameter/required b/sami/my-cdist/.cdist/type/__sample_nginx_http_letsencrypt_and_ssl_redirect/parameter/required deleted file mode 100644 index fc7c3e9..0000000 --- a/sami/my-cdist/.cdist/type/__sample_nginx_http_letsencrypt_and_ssl_redirect/parameter/required +++ /dev/null @@ -1 +0,0 @@ -webroot From 1176f213145a1d400d01df2190709c6c562c0909 Mon Sep 17 00:00:00 2001 From: samuel Date: Mon, 11 May 2020 12:22:12 +0200 Subject: [PATCH 2/2] gencode --- sami/my-cdist/.cdist/type/__nginx/manifest | 1 + sami/my-cdist/.cdist/type/__nginx/singleton | 0 .../.cdist/type/__nginx_site/gencode-remote | 3 +++ .../.cdist/type/__nginx_site/manifest | 21 +++++++++++++++++++ 4 files changed, 25 insertions(+) create mode 100644 sami/my-cdist/.cdist/type/__nginx/manifest create mode 100644 sami/my-cdist/.cdist/type/__nginx/singleton create mode 100644 sami/my-cdist/.cdist/type/__nginx_site/gencode-remote create mode 100644 sami/my-cdist/.cdist/type/__nginx_site/manifest diff --git a/sami/my-cdist/.cdist/type/__nginx/manifest b/sami/my-cdist/.cdist/type/__nginx/manifest new file mode 100644 index 0000000..f9b246e --- /dev/null +++ b/sami/my-cdist/.cdist/type/__nginx/manifest @@ -0,0 +1 @@ +__package nginx --state present diff --git a/sami/my-cdist/.cdist/type/__nginx/singleton b/sami/my-cdist/.cdist/type/__nginx/singleton new file mode 100644 index 0000000..e69de29 diff --git a/sami/my-cdist/.cdist/type/__nginx_site/gencode-remote b/sami/my-cdist/.cdist/type/__nginx_site/gencode-remote new file mode 100644 index 0000000..2c5a080 --- /dev/null +++ b/sami/my-cdist/.cdist/type/__nginx_site/gencode-remote @@ -0,0 +1,3 @@ +# Reacting on message + +echo "service nginx reload" diff --git a/sami/my-cdist/.cdist/type/__nginx_site/manifest b/sami/my-cdist/.cdist/type/__nginx_site/manifest new file mode 100644 index 0000000..3fa56dc --- /dev/null +++ b/sami/my-cdist/.cdist/type/__nginx_site/manifest @@ -0,0 +1,21 @@ + +os=$(cat "$__global/explorer/os") + +domain="$__object_id" +nginx_config_dir="/etc/nginx/conf.d" + +require="__package/nginx" __file $nginx_config_dir/$domain.conf --source - << EOF + +server { + + server_name $domain; + listen [::]:80 ; + + location / { + autoindex on; + root /var/www/html/$domain; + } +} +EOF + +