From 13e0517c93b8affec1fcc5bae436cccbaa1f2286 Mon Sep 17 00:00:00 2001 From: elf Date: Mon, 11 May 2020 23:51:46 +0900 Subject: [PATCH] [cdist #4]create nginx test --- kjg/cdist.org | 58 ++++++++++++++++++++ kjg/dot-cdist/manifest/init | 3 + kjg/dot-cdist/type/__my_nginx/manifest | 3 + kjg/dot-cdist/type/__my_nginx/singleton | 0 kjg/dot-cdist/type/__my_nginx_site/manifest | 29 ++++++++++ kjg/dot-cdist/type/__my_nginx_site/manifest~ | 33 +++++++++++ 6 files changed, 126 insertions(+) create mode 100644 kjg/dot-cdist/type/__my_nginx/manifest create mode 100644 kjg/dot-cdist/type/__my_nginx/singleton create mode 100644 kjg/dot-cdist/type/__my_nginx_site/manifest create mode 100644 kjg/dot-cdist/type/__my_nginx_site/manifest~ diff --git a/kjg/cdist.org b/kjg/cdist.org index 4fb319c..2349cf7 100644 --- a/kjg/cdist.org +++ b/kjg/cdist.org @@ -1002,4 +1002,62 @@ TRACE: localhost: Saving cache: /tmp/tmp4n4p2hbt/421aa90e079fa326b6494f812ad13e7 INFO: localhost: Finished successful run in 2.17 seconds 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 +*** log +VERBOSE: cdist: version 6.5.5-3-g6f4649ef +INFO: localhost: Starting configuration run +VERBOSE: localhost: Running global explorers +VERBOSE: localhost: Running initial manifest /tmp/tmpchto21_m/421aa90e079fa326b6494f812ad13e79/data/conf/manifest/init +VERBOSE: localhost: Preparing object __my_nginx/ +VERBOSE: localhost: Running manifest and explorers for __my_nginx/ +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running type manifest /tmp/tmpchto21_m/421aa90e079fa326b6494f812ad13e79/data/conf/type/__my_nginx/manifest for object __my_nginx/ +VERBOSE: localhost: Preparing object __package/nginx +VERBOSE: localhost: Running manifest and explorers for __package/nginx +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running type manifest /tmp/tmpchto21_m/421aa90e079fa326b6494f812ad13e79/data/conf/type/__package/manifest for object __package/nginx +VERBOSE: localhost: Preparing object __package_apt/nginx +VERBOSE: localhost: Running manifest and explorers for __package_apt/nginx +VERBOSE: localhost: Running type explorers for +VERBOSE: localhost: Running object __package_apt/nginx +VERBOSE: localhost: Running object __package/nginx +VERBOSE: localhost: Running object __my_nginx/ +INFO: localhost: Finished successful run in 0.87 seconds +VERBOSE: config: Total processing time for 1 host(s): 0.8785049915313721 +** Create a new tyep *__my_nginx_site* +root@mynginx2:~#ls -al /etc/nginx/sites-enabled/ +total 16 +drwxr-xr-x 2 root root 4096 May 11 23:29 . +drwxr-xr-x 8 root root 4096 May 11 21:40 .. +lrwxrwxrwx 1 root root 34 May 11 21:40 default -> /etc/nginx/sites-available/default +-rw-r--r-- 1 root root 243 May 11 23:29 mynginx2.test.conf +-rw-r--r-- 1 root root 243 May 11 23:27 mynginx.test.conf +root@mynginx2:~# + +*** remove nginx and __my_nginx log +VERBOSE: cdist: version 6.5.5-3-g6f4649ef +INFO: mynginx2.test: Starting configuration run +VERBOSE: mynginx2.test: Running global explorers +VERBOSE: mynginx2.test: Running initial manifest /tmp/tmptq3y42m2/5e977ddad9a0047b183b6d2702795df4/data/conf/manifest/init +VERBOSE: mynginx2.test: Preparing object __my_nginx_site/mynginx2.test +VERBOSE: mynginx2.test: Running manifest and explorers for __my_nginx_site/mynginx2.test +VERBOSE: mynginx2.test: Running type explorers for +VERBOSE: mynginx2.test: Running type manifest /tmp/tmptq3y42m2/5e977ddad9a0047b183b6d2702795df4/data/conf/type/__my_nginx_site/manifest for object __my_nginx_site/mynginx2.test +ERROR: mynginx2.test: The requirements of the following objects could not be resolved: +__file/etc/nginx/sites-enabled/mynginx2.test.conf requires: + __package/nginx +__file/etc/nginx/sites-enabled/mynginx2.test.conf autorequires: + +__my_nginx_site/mynginx2.test requires: + +__my_nginx_site/mynginx2.test autorequires: + __file/etc/nginx/sites-enabled/mynginx2.test.conf +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) diff --git a/kjg/dot-cdist/manifest/init b/kjg/dot-cdist/manifest/init index a7829eb..02a4738 100644 --- a/kjg/dot-cdist/manifest/init +++ b/kjg/dot-cdist/manifest/init @@ -5,4 +5,7 @@ case "$__target_host" in #__colourful_file test --colour test1 --colour test2 __my_dotfiles ;; + *) + #__my_nginx + __my_nginx_site $__target_host esac diff --git a/kjg/dot-cdist/type/__my_nginx/manifest b/kjg/dot-cdist/type/__my_nginx/manifest new file mode 100644 index 0000000..c231a90 --- /dev/null +++ b/kjg/dot-cdist/type/__my_nginx/manifest @@ -0,0 +1,3 @@ +#!/bin/sh + +__package nginx diff --git a/kjg/dot-cdist/type/__my_nginx/singleton b/kjg/dot-cdist/type/__my_nginx/singleton new file mode 100644 index 0000000..e69de29 diff --git a/kjg/dot-cdist/type/__my_nginx_site/manifest b/kjg/dot-cdist/type/__my_nginx_site/manifest new file mode 100644 index 0000000..c5a6df8 --- /dev/null +++ b/kjg/dot-cdist/type/__my_nginx_site/manifest @@ -0,0 +1,29 @@ +#!/bin/sh + + +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" \ + --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 diff --git a/kjg/dot-cdist/type/__my_nginx_site/manifest~ b/kjg/dot-cdist/type/__my_nginx_site/manifest~ new file mode 100644 index 0000000..6677dcc --- /dev/null +++ b/kjg/dot-cdist/type/__my_nginx_site/manifest~ @@ -0,0 +1,33 @@ +#!/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