Commit 4106e1cf authored by Alain Takoudjou's avatar Alain Takoudjou

caddy-fronted: migrate promises to new format

parent 8c637dbc
......@@ -22,7 +22,7 @@ md5sum = c801b7f9f11f0965677c22e6bbe9281b
[template-apache-frontend]
filename = instance-apache-frontend.cfg.in
md5sum = da7b5804d50c727412885e8b818ca433
md5sum = 6fd023f0d29421d8579f0b3351473bb0
[template-apache-replicate]
filename = instance-apache-replicate.cfg.in
......@@ -30,7 +30,7 @@ md5sum = 86f15c85054800a55a7093d37b03cdce
[template-slave-list]
filename = templates/apache-custom-slave-list.cfg.in
md5sum = 5b91c0079b42780054da004f8fc6f26b
md5sum = 439a4e415bef9d44b37bee4d5e4aa924
[template-slave-configuration]
filename = templates/custom-virtualhost.conf.in
......
......@@ -29,6 +29,8 @@ parts +=
http-proxy
caddyprofiledeps
# ==================
[caddyprofiledeps-setup]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/setup.py
......
......@@ -75,6 +75,7 @@ run = ${:var}/run
service = ${:etc}/service
etc-run = ${:etc}/run
promise = ${:etc}/promise
plugin = ${:etc}/plugin
logrotate-backup = ${:backup}/logrotate
logrotate-entries = ${:etc}/logrotate.d
......@@ -194,6 +195,7 @@ extra-context =
section caddy_configuration caddy-configuration
section nginx_configuration nginx-configuration
key monitor_base_url monitor-instance-parameter:monitor-base-url
key plugin_directory directory:plugin
key promise_directory directory:promises
key report_directory directory:bin
key bin_directory :bin_directory
......@@ -510,11 +512,21 @@ filename = plugin.config
context =
key content trafficserver-variable:plugin-config
[promise-plugin-base]
recipe = slapos.cookbook:promise.plugin
eggs =
slapos.toolbox
content =
from slapos.promise.plugin.${:module} import RunPromise
output = ${directory:plugin}/${:name}
[trafficserver-promise-listen-port]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/trafficserver-port-listening
hostname = ${trafficserver-variable:local-ip}
port = ${trafficserver-variable:input-port}
<= promise-plugin-base
module = check_port_listening
name = trafficserver-port-listening.py
config-hostname = ${trafficserver-variable:local-ip}
config-port = ${trafficserver-variable:input-port}
[trafficserver-line]
recipe = slapos.cookbook:wrapper
......@@ -523,18 +535,10 @@ wrapper-path = ${directory:bin}/traffic_line
environment = TS_ROOT=${buildout:directory}
[trafficserver-promise-cache-availability]
recipe = collective.recipe.template
input =
inline:#!${buildout:executable}
import subprocess
import sys
traffic_line = "${trafficserver-line:wrapper-path}"
result = float(subprocess.check_output([traffic_line, '-r', 'proxy.node.cache.percent_free' ]))
if result != 0: sys.exit(0)
sys.stderr.write("Cache not available, availability: %s" % result)
sys.exit(127)
output = ${directory:promise}/trafficserver-cache-availability
mode = 700
<= promise-plugin-base
module = trafficserver_cache_availability
name = trafficserver-cache-availability.py
config-wrapper-path = ${trafficserver-line:wrapper-path}
### End of ATS sections
......@@ -607,45 +611,52 @@ extra-context =
# Promises checking configuration:
[promise-frontend-caddy-configuration]
recipe = slapos.cookbook:wrapper
command-line = ${caddy-configuration:frontend-configuration-verification}
wrapper-path = ${directory:promise}/frontend-caddy-configuration-promise
<= promise-plugin-base
module = validate_frontend_configuration
name = frontend-caddy-configuration-promise.py
config-verification-script = ${caddy-configuration:frontend-configuration-verification}
[promise-caddy-frontend-v4-https]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/caddy_frontend_ipv4_https
hostname = {{ instance_parameter['ipv4-random'] }}
port = ${configuration:port}
<= promise-plugin-base
module = check_port_listening
name = caddy_frontend_ipv4_https.py
config-hostname = {{ instance_parameter['ipv4-random'] }}
config-port = ${configuration:port}
[promise-caddy-frontend-v4-http]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/caddy_frontend_ipv4_http
hostname = {{ instance_parameter['ipv4-random'] }}
port = ${configuration:plain_http_port}
<= promise-plugin-base
module = check_port_listening
name = caddy_frontend_ipv4_http.py
config-hostname = {{ instance_parameter['ipv4-random'] }}
config-port = ${configuration:plain_http_port}
[promise-caddy-frontend-v6-https]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/caddy_frontend_ipv6_https
hostname = {{ instance_parameter['ipv6-random'] }}
port = ${configuration:port}
<= promise-plugin-base
module = check_port_listening
name = caddy_frontend_ipv6_https.py
config-hostname = {{ instance_parameter['ipv6-random'] }}
config-port = ${configuration:port}
[promise-caddy-frontend-v6-http]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/caddy_frontend_ipv6_http
hostname = {{ instance_parameter['ipv6-random'] }}
port = ${configuration:plain_http_port}
<= promise-plugin-base
module = check_port_listening
name = caddy_frontend_ipv6_http.py
config-hostname = {{ instance_parameter['ipv6-random'] }}
config-port = ${configuration:plain_http_port}
[promise-caddy-frontend-cached]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/caddy_cached
hostname = {{ instance_parameter['ipv4-random'] }}
port = ${caddy-configuration:cache-through-port}
<= promise-plugin-base
module = check_port_listening
name = caddy_cached.py
config-hostname = {{ instance_parameter['ipv4-random'] }}
config-port = ${caddy-configuration:cache-through-port}
[promise-caddy-frontend-ssl-cached]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/caddy_ssl_cached
hostname = {{ instance_parameter['ipv4-random'] }}
port = ${caddy-configuration:ssl-cache-through-port}
<= promise-plugin-base
module = check_port_listening
name = caddy_ssl_cached.py
config-hostname = {{ instance_parameter['ipv4-random'] }}
config-port = ${caddy-configuration:ssl-cache-through-port}
[promise-caddy-is-process-older-than-dependency-set]
recipe = slapos.cookbook:wrapper
......@@ -707,11 +718,10 @@ context =
raw content show:cache-stats
[monitor-verify-re6st-connectivity]
recipe = slapos.cookbook:check_url_available
path = ${directory:promise}/re6st-connectivity
url = ${configuration:re6st-verification-url}
dash_path = {{ parameter_dict['dash'] }}/bin/dash
curl_path = {{ parameter_dict['curl'] }}/bin/curl
<= promise-plugin-base
module = check_url_available
name = re6st-connectivity.py
config-url = ${configuration:re6st-verification-url}
#######################
# Nginx
......@@ -772,33 +782,38 @@ ssl_certificate = ${ca-frontend:cert-file}
ssl_key = ${ca-frontend:key-file}
[promise-nginx-configuration]
recipe = slapos.cookbook:wrapper
command-line = ${nginx-configuration:nginx-configuration-verification}
wrapper-path = ${directory:promise}/nginx-configuration-promise
<= promise-plugin-base
module = validate_frontend_configuration
name = nginx-configuration-promise.py
config-verification-script = ${nginx-configuration:nginx-configuration-verification}
[promise-nginx-frontend-v4-https]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/nginx_frontend_ipv4_https
hostname = {{ instance_parameter['ipv4-random'] }}
port = ${configuration:nginx_port}
<= promise-plugin-base
module = check_port_listening
name = nginx_frontend_ipv4_https.py
config-hostname = {{ instance_parameter['ipv4-random'] }}
config-port = ${configuration:nginx_port}
[promise-nginx-frontend-v4-http]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/nginx_frontend_ipv4_http
hostname = {{ instance_parameter['ipv4-random'] }}
port = ${configuration:plain_nginx_port}
<= promise-plugin-base
module = check_port_listening
name = nginx_frontend_ipv4_http.py
config-hostname = {{ instance_parameter['ipv4-random'] }}
config-port = ${configuration:plain_nginx_port}
[promise-nginx-frontend-v6-https]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/nginx_frontend_ipv6_https
hostname = {{ instance_parameter['ipv6-random'] }}
port = ${configuration:nginx_port}
<= promise-plugin-base
module = check_port_listening
name = nginx_frontend_ipv6_https.py
config-hostname = {{ instance_parameter['ipv6-random'] }}
config-port = ${configuration:nginx_port}
[promise-nginx-frontend-v6-http]
recipe = slapos.cookbook:check_port_listening
path = ${directory:promise}/nginx_frontend_ipv6_http
hostname = {{ instance_parameter['ipv6-random'] }}
port = ${configuration:plain_nginx_port}
<= promise-plugin-base
module = check_port_listening
name = nginx_frontend_ipv6_http.py
config-hostname = {{ instance_parameter['ipv6-random'] }}
config-port = ${configuration:plain_nginx_port}
[promise-nginx-is-process-older-than-dependency-set]
recipe = slapos.cookbook:wrapper
......
......@@ -44,6 +44,14 @@ certs = {{ custom_ssl_directory }}/certs/
newcerts = {{ custom_ssl_directory }}/newcerts/
crl = {{ custom_ssl_directory }}/crl/
[promise-plugin-base]
recipe = slapos.cookbook:promise.plugin
eggs =
slapos.toolbox
content =
from slapos.promise.plugin.${:module} import RunPromise
output = {{ plugin_directory }}/${:name}
{# Loop thought slave list to set up slaves #}
{% for slave_instance in slave_instance_list %}
{% set slave_reference = slave_instance.get('slave_reference') %}
......@@ -276,28 +284,36 @@ extra-context =
{% set check_error_log_section_title = 'check-%s-error-log-last-hour' % slave_instance.get('slave_reference') %}
{% do part_list.append(check_error_log_section_title) %}
[{{ check_error_log_section_title }}]
recipe = slapos.cookbook:wrapper
command-line = {{ bin_directory }}/check-error-on-apache-log -l {{ slave_instance.get('error_log') }} -d 3600
filename = {{ check_error_log_section_title }}
wrapper-path = {{ promise_directory }}/${:filename}
<= promise-plugin-base
module = check_error_on_http_log
name = {{ check_error_log_section_title }}.py
config-log-file = {{ slave_instance.get('error_log') }}
config-maximum-delay = 3600
# promise frequency in minutes (2 times/day)
config-frequency = 720
{% set check_error_log_section_title = 'check-%s-error-log-last-day' % slave_instance.get('slave_reference') %}
{% do part_list.append(check_error_log_section_title) %}
[{{ check_error_log_section_title }}]
recipe = slapos.cookbook:wrapper
command-line = {{ bin_directory }}/check-error-on-apache-log -l {{ slave_instance.get('error_log') }} -d 86400
filename = {{ check_error_log_section_title }}
wrapper-path = {{ promise_directory }}/${:filename}
<= promise-plugin-base
module = check_error_on_http_log
name = {{ check_error_log_section_title }}.py
config-log-file = {{ slave_instance.get('error_log') }}
config-maximum-delay = 86400
# promise frequency in minutes (2 times/day)
config-frequency = 720
{% set monitor_ipv6_test = slave_instance.get('monitor-ipv6-test', '') %}
{% if monitor_ipv6_test %}
{% set monitor_ipv6_section_title = 'check-%s-ipv6-packet-list-test' % slave_instance.get('slave_reference') %}
{% do part_list.append(monitor_ipv6_section_title) %}
[{{ monitor_ipv6_section_title }}]
recipe = slapos.cookbook:wrapper
command-line = {{ dumps(bin_directory ~ '/is-icmp-packet-lost -a ' ~ monitor_ipv6_test) }}
filename = {{ monitor_ipv6_section_title }}
wrapper-path = {{ promise_directory }}/${:filename}
<= promise-plugin-base
module = check_icmp_packet_lost
name = {{ monitor_ipv6_section_title }}.py
config-address = {{ dumps(monitor_ipv6_test) }}
# promise frequency in minutes (2 times/day)
config-frequency = 720
{% endif %}
{% set monitor_ipv4_test = slave_instance.get('monitor-ipv4-test', '') %}
......@@ -305,10 +321,13 @@ wrapper-path = {{ promise_directory }}/${:filename}
{% set monitor_ipv4_section_title = 'check-%s-ipv4-packet-list-test' % slave_instance.get('slave_reference') %}
{% do part_list.append(monitor_ipv4_section_title) %}
[{{ monitor_ipv4_section_title }}]
recipe = slapos.cookbook:wrapper
command-line = {{ dumps(bin_directory ~ '/is-icmp-packet-lost -4 -a ' ~ monitor_ipv4_test) }}
filename = {{ monitor_ipv4_section_title }}
wrapper-path = {{ promise_directory }}/${:filename}
<= promise-plugin-base
module = check_icmp_packet_lost
name = {{ monitor_ipv4_section_title }}.py
config-address = {{ dumps(monitor_ipv4_test) }}
config-ipv4 = true
# promise frequency in minutes (2 times/day)
config-frequency = 720
{% endif %}
{% set re6st_optimal_test = '' ~ slave_instance.get('re6st-optimal-test', '') %}
......@@ -322,10 +341,13 @@ wrapper-path = {{ promise_directory }}/${:filename}
{% do part_list.append(re6st_optimal_test_section_title) %}
[{{ re6st_optimal_test_section_title }}]
recipe = slapos.cookbook:wrapper
command-line = {{ dumps(bin_directory ~ '/check-re6st-optimal-status -4 ' ~ re6st_ipv4 ~ ' -6 ' ~ re6st_ipv6) }}
filename = {{ re6st_optimal_test_section_title }}
wrapper-path = {{ promise_directory }}/${:filename}
<= promise-plugin-base
module = check_re6st_optimal_status
name = {{ re6st_optimal_test_section_title }}.py
config-ipv4 = {{ dumps(re6st_ipv4) }}
config-ipv6 = {{ dumps(re6st_ipv6) }}
# promise frequency in minutes (2 times/day)
config-frequency = 720
{% endif %}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment