Learning Circle : cidst #5 - initial commit
This commit is contained in:
parent
2a07d12665
commit
46e78f1a15
9 changed files with 153 additions and 2 deletions
|
@ -5,11 +5,16 @@ case "$__target_host" in
|
|||
__motd
|
||||
__timezone Asia/Seoul
|
||||
# __my_computer
|
||||
__colourful_file --colour yellow
|
||||
# __colourful_file --colour yellow
|
||||
__my_nginx_site $__target_host
|
||||
;;
|
||||
jafo.laptop)
|
||||
__motd
|
||||
__timezone Asia/Seoul
|
||||
__my_computer
|
||||
# __my_computer
|
||||
;;
|
||||
*)
|
||||
# __my_nginx
|
||||
__my_nginx_site $__target_host
|
||||
;;
|
||||
esac
|
||||
|
|
0
youngjin.han/dot-cdist/type/__colourful_file/manifest
Normal file → Executable file
0
youngjin.han/dot-cdist/type/__colourful_file/manifest
Normal file → Executable file
8
youngjin.han/dot-cdist/type/__my_nginx/manifest
Executable file
8
youngjin.han/dot-cdist/type/__my_nginx/manifest
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# update package index
|
||||
__apt_update_index
|
||||
|
||||
require="__apt_update_index" __package nginx --state=present
|
||||
|
||||
|
0
youngjin.han/dot-cdist/type/__my_nginx/singleton
Normal file
0
youngjin.han/dot-cdist/type/__my_nginx/singleton
Normal file
|
@ -0,0 +1 @@
|
|||
echo "sudo service nginx reload"
|
|
@ -0,0 +1 @@
|
|||
echo "service nginx reload"
|
42
youngjin.han/dot-cdist/type/__my_nginx_site/manifest
Executable file
42
youngjin.han/dot-cdist/type/__my_nginx_site/manifest
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
nginx_config_dir="/etc/nginx/conf.d"
|
||||
domain="$__object_id"
|
||||
|
||||
__directory /var/www/html/$domain \
|
||||
--parents --mode 0644
|
||||
|
||||
require="__directory//var/www/html/$domain" \
|
||||
__file /var/www/html/$domain/index.html \
|
||||
--source - --mode 0644 << EOF
|
||||
Hello Cdist!!!
|
||||
EOF
|
||||
|
||||
__my_nginx
|
||||
|
||||
# configure nginx
|
||||
require="__my_nginx" \
|
||||
__file "$nginx_config_dir/${domain}.conf" \
|
||||
--mode 0644 --source - << EOF
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name $domaini;
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
|
||||
client_max_body_size 256m;
|
||||
|
||||
location / {
|
||||
root /var/www/html/$domain;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
|
||||
location = /50x.html {
|
||||
root /var/www/html/$domain;
|
||||
}
|
||||
}
|
||||
EOF
|
42
youngjin.han/dot-cdist/type/__my_nginx_site/manifest~
Executable file
42
youngjin.han/dot-cdist/type/__my_nginx_site/manifest~
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
nginx_config_dir="/etc/nginx/conf.d"
|
||||
domain="$__object_id"
|
||||
|
||||
__directory /var/www/html/$domain \
|
||||
--parents --mode 0644
|
||||
|
||||
require="__directory//var/www/html/$domain" \
|
||||
__file /var/www/html/$domain/index.html \
|
||||
--source - --mode 0644 << EOF
|
||||
Hello Cdist!!!
|
||||
EOF
|
||||
|
||||
__my_nginx
|
||||
|
||||
# configure nginx
|
||||
require="__my_nginx" \
|
||||
__file "$nginx_config_dir/${domain}.conf" \
|
||||
--mode 0644 --source - << EOF
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name $domain;
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
|
||||
client_max_body_size 256m;
|
||||
|
||||
location / {
|
||||
root /var/www/html/$domain;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
|
||||
location = /50x.html {
|
||||
root /var/www/html/$domain;
|
||||
}
|
||||
}
|
||||
EOF
|
|
@ -1,3 +1,55 @@
|
|||
* 2020-05-13
|
||||
*** cdist #5: Generating Code & Exploring
|
||||
**** Lecture content
|
||||
***** Objective
|
||||
- Understand how to *generate code* and when to use it
|
||||
- Exploring explorers
|
||||
***** Code generation steps
|
||||
- Modify the previously created type *__my_nginx_site*
|
||||
- Read about cdist messaging
|
||||
- If there was a change in the nginx configuration file, reload nginx
|
||||
***** Explorer steps
|
||||
- Modify the *__my_nginx_site* type to use the *os explorer*
|
||||
- Adjust your type to work on Alpine Linux and Debian (or two
|
||||
other Linux distributions of your choice)
|
||||
- Set the nginx configuration directory accordingly
|
||||
***** Documentation
|
||||
- Explain the following in your cdist.org file
|
||||
- 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?
|
||||
* 2020-05-11
|
||||
*** cdist #4: Requirements
|
||||
**** Lecture content
|
||||
***** Objective
|
||||
****** Understand how requirements work
|
||||
***** DONE Create a new type *__my_nginx*
|
||||
CLOSED: [2020-05-12 화 02:22]
|
||||
****** Make it a *singleton*
|
||||
****** Make it install nginx
|
||||
****** Configure a host with it
|
||||
****** Usually nginx is configured includes some files
|
||||
****** On the target host find out which directory nginx includes
|
||||
****** We name this directory *nginx_config_dir*
|
||||
***** DONE Create a new type *__my_nginx_site*
|
||||
CLOSED: [2020-05-12 화 02:22]
|
||||
****** Assume the *object_id* is a *domain*
|
||||
****** In the __my_nginx_site create a file inside the *nginx_config_dir*
|
||||
****** The filename is *${domain}.conf*
|
||||
****** When using *__file*, it should *require* the *nginx package*
|
||||
******* Read about cdist dependencies
|
||||
****** The file should be a valid nginx configuration
|
||||
****** The *server name* should be set to the specified domain
|
||||
****** The *root* directive should point to /var/www/html/DOMAIN
|
||||
******* (replace DOMAIN with the actual domain)
|
||||
***** Use both types in the initial manifest to configure the target host
|
||||
****** Create at least two domains
|
||||
***** Configure the target host
|
||||
****** Verify that the configuration files are properly created
|
||||
***** Delete the nginx package manually on the target host
|
||||
***** Comment out *__my_nginx* from the initial manifest, keep the *__my_nginx_site*
|
||||
****** Explain the error that you get (in your cdist.org file)
|
||||
* 2020-05-08
|
||||
*** cdist #3: type parameters
|
||||
**** Lecture content
|
||||
|
|
Loading…
Reference in a new issue