[cdist #5] modify __my_nginx_site
This commit is contained in:
parent
13e0517c93
commit
3a84ac767e
5 changed files with 46 additions and 39 deletions
|
@ -1005,6 +1005,7 @@ VERBOSE: config: Total processing time for 1 host(s): 2.1842637062072754
|
||||||
|
|
||||||
* cdist3
|
* cdist3
|
||||||
|
|
||||||
|
|
||||||
* cdist4
|
* cdist4
|
||||||
** Create a new type *__my_nginx*
|
** Create a new type *__my_nginx*
|
||||||
On the target host find out which directory nginx includes --> /etc/nginx/sites-enabled
|
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
|
ERROR: cdist: Failed to configure the following hosts: mynginx2.tes
|
||||||
|
|
||||||
--> nginx is removed and "require" check nginx(__package/nginx)
|
--> 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?
|
||||||
|
|
|
@ -6,6 +6,6 @@ case "$__target_host" in
|
||||||
__my_dotfiles
|
__my_dotfiles
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
#__my_nginx
|
__my_nginx
|
||||||
__my_nginx_site $__target_host
|
__my_nginx_site $__target_host
|
||||||
esac
|
esac
|
||||||
|
|
20
kjg/dot-cdist/type/__my_nginx_site/gencode-remote
Normal file
20
kjg/dot-cdist/type/__my_nginx_site/gencode-remote
Normal file
|
@ -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
|
|
@ -1,11 +1,23 @@
|
||||||
#!/bin/sh
|
#!/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"
|
DOMAIN_NAME="$__object_id"
|
||||||
CONF_DIR=/etc/nginx/sites-enabled
|
|
||||||
WEB_ROOT=/var/www/html/${DOMAIN_NAME}
|
WEB_ROOT=/var/www/html/${DOMAIN_NAME}
|
||||||
|
|
||||||
|
|
||||||
__directory $WEB_ROOT --parents --mode 0644
|
__directory $WEB_ROOT --parents --mode 0644
|
||||||
|
|
||||||
require="__package/nginx" __file "${CONF_DIR}/${DOMAIN_NAME}.conf" \
|
require="__package/nginx" __file "${CONF_DIR}/${DOMAIN_NAME}.conf" \
|
||||||
|
@ -14,11 +26,11 @@ server {
|
||||||
listen *:80;
|
listen *:80;
|
||||||
listen [::]:80;
|
listen [::]:80;
|
||||||
|
|
||||||
server_name $name;
|
server_name $DOMAIN_NAME;
|
||||||
root $WEBROOT;
|
root $WEB_ROOT;
|
||||||
|
|
||||||
location /.well-known/acme-challenge/ {
|
location /.well-known/acme-challenge/ {
|
||||||
root $WEBROOT;
|
root $WEB_ROOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Everything else -> ssl
|
# Everything else -> ssl
|
||||||
|
|
|
@ -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
|
|
Loading…
Reference in a new issue