diff --git a/kjg/cdist.org b/kjg/cdist.org index 2349cf7..530009c 100644 --- a/kjg/cdist.org +++ b/kjg/cdist.org @@ -1005,6 +1005,7 @@ VERBOSE: config: Total processing time for 1 host(s): 2.1842637062072754 * cdist3 + * cdist4 ** Create a new type *__my_nginx* On the target host find out which directory nginx includes --> /etc/nginx/sites-enabled @@ -1061,3 +1062,10 @@ VERBOSE: config: Total processing time for 1 host(s): 0.6650142669677734 ERROR: cdist: Failed to configure the following hosts: mynginx2.tes --> nginx is removed and "require" check nginx(__package/nginx) + +* cdist5 +** What is the difference between gencode-remote and the remote code? + +** What is the difference between gencode-local and gencode-remote? + +** Locate a type that comes with upstream cdist that uses gencode-local - which one is it? Why does it need gencode-local? diff --git a/kjg/dot-cdist/manifest/init b/kjg/dot-cdist/manifest/init index 02a4738..ba3b873 100644 --- a/kjg/dot-cdist/manifest/init +++ b/kjg/dot-cdist/manifest/init @@ -6,6 +6,6 @@ case "$__target_host" in __my_dotfiles ;; *) - #__my_nginx + __my_nginx __my_nginx_site $__target_host esac diff --git a/kjg/dot-cdist/type/__my_nginx_site/gencode-remote b/kjg/dot-cdist/type/__my_nginx_site/gencode-remote new file mode 100644 index 0000000..e18e240 --- /dev/null +++ b/kjg/dot-cdist/type/__my_nginx_site/gencode-remote @@ -0,0 +1,20 @@ +os=$(cat "$__global/explorer/os") + +case "$os" in + devuan) + CONF_DIR=/etc/nginx/sites-enabled + ;; + alpine) + CONF_DIR=/etc/nginx/conf.d + ;; + *) + echo "OS $os currently not supported" >&2 + exit 1 + ;; +esac + +DOMAIN_NAME="$__object_id" + +if grep -q "^__file${CONF_DIR}/${DOMAIN_NAME}" "$__messages_in"; then + echo 'service nginx reload' +fi diff --git a/kjg/dot-cdist/type/__my_nginx_site/manifest b/kjg/dot-cdist/type/__my_nginx_site/manifest index c5a6df8..3362f90 100644 --- a/kjg/dot-cdist/type/__my_nginx_site/manifest +++ b/kjg/dot-cdist/type/__my_nginx_site/manifest @@ -1,11 +1,23 @@ #!/bin/sh +os=$(cat "$__global/explorer/os") + +case "$os" in + devuan) + CONF_DIR=/etc/nginx/sites-enabled + ;; + alpine) + CONF_DIR=/etc/nginx/conf.d + ;; + *) + echo "OS $os currently not supported" >&2 + exit 1 + ;; +esac DOMAIN_NAME="$__object_id" -CONF_DIR=/etc/nginx/sites-enabled WEB_ROOT=/var/www/html/${DOMAIN_NAME} - __directory $WEB_ROOT --parents --mode 0644 require="__package/nginx" __file "${CONF_DIR}/${DOMAIN_NAME}.conf" \ @@ -14,11 +26,11 @@ server { listen *:80; listen [::]:80; - server_name $name; - root $WEBROOT; + server_name $DOMAIN_NAME; + root $WEB_ROOT; location /.well-known/acme-challenge/ { - root $WEBROOT; + root $WEB_ROOT; } # Everything else -> ssl diff --git a/kjg/dot-cdist/type/__my_nginx_site/manifest~ b/kjg/dot-cdist/type/__my_nginx_site/manifest~ deleted file mode 100644 index 6677dcc..0000000 --- a/kjg/dot-cdist/type/__my_nginx_site/manifest~ +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - - -DOMAIN_NAME="$__object_id" -CONF_DIR=/etc/nginx/sites-enabled -WEB_ROOT=/var/www/html/${DOMAIN_NAME} - -#__package nginx --state installed - - - - - -#require="__package/nginx" __file "~/ungleich-learning/test.conf" \ -require="__package/nginx" __file "${CONF_DIR}/${DOMAIN_NAME}.conf" \ - --mode 0644 --source - << EOF -server { - listen *:80; - listen [::]:80; - - server_name $name; - root $WEBROOT; - - location /.well-known/acme-challenge/ { - root $WEBROOT; - } - - # Everything else -> ssl - location / { - return 301 https://\$host\$request_uri; - } -} -EOF \ No newline at end of file