Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aurel
slapos
Commits
dcafa44a
Commit
dcafa44a
authored
Feb 08, 2019
by
Łukasz Nowak
Committed by
Łukasz Nowak
Feb 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caddy-frontend: Treat None as non existing parameters
parent
1707af40
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
27 deletions
+40
-27
software/caddy-frontend/buildout.hash.cfg
software/caddy-frontend/buildout.hash.cfg
+2
-2
software/caddy-frontend/instance-apache-replicate.cfg.in
software/caddy-frontend/instance-apache-replicate.cfg.in
+12
-11
software/caddy-frontend/templates/apache-custom-slave-list.cfg.in
.../caddy-frontend/templates/apache-custom-slave-list.cfg.in
+26
-14
No files found.
software/caddy-frontend/buildout.hash.cfg
View file @
dcafa44a
...
@@ -26,11 +26,11 @@ md5sum = da7b5804d50c727412885e8b818ca433
...
@@ -26,11 +26,11 @@ md5sum = da7b5804d50c727412885e8b818ca433
[template-apache-replicate]
[template-apache-replicate]
filename = instance-apache-replicate.cfg.in
filename = instance-apache-replicate.cfg.in
md5sum =
6a86edb96b171fbd0a59d0adc9cc906b
md5sum =
86f15c85054800a55a7093d37b03cdce
[template-slave-list]
[template-slave-list]
filename = templates/apache-custom-slave-list.cfg.in
filename = templates/apache-custom-slave-list.cfg.in
md5sum =
d476a5d21d448bcad0ab48494b229e28
md5sum =
5b91c0079b42780054da004f8fc6f26b
[template-slave-configuration]
[template-slave-configuration]
filename = templates/custom-virtualhost.conf.in
filename = templates/custom-virtualhost.conf.in
...
...
software/caddy-frontend/instance-apache-replicate.cfg.in
View file @
dcafa44a
...
@@ -80,19 +80,19 @@ context =
...
@@ -80,19 +80,19 @@ context =
{% do used_host_list.append(custom_domain) %}
{% do used_host_list.append(custom_domain) %}
{% endif %}
{% endif %}
{% if slave.get('server-alias') %}
{% if slave.get('server-alias') %}
{% for slave_alias in
slave['server-alias']
.split() %}
{% for slave_alias in
('' ~ slave['server-alias'])
.split() %}
{% if slave_alias.startswith('*.') %}
{% if slave_alias.startswith('*.') %}
{% set clean_slave_alias = slave_alias[2:] %}
{% set clean_slave_alias = slave_alias[2:] %}
{% else %}
{% else %}
{% set clean_slave_alias = slave_alias %}
{% set clean_slave_alias = slave_alias %}
{% endif %}
{% endif %}
{% if not validators.domain(clean_slave_alias) %}
{% if not validators.domain(clean_slave_alias) %}
{% do slave_error_list.append('server-alias
%r
not valid' % (slave_alias,)) %}
{% do slave_error_list.append('server-alias
\'%s\'
not valid' % (slave_alias,)) %}
{% else %}
{% else %}
{% if slave_alias in slave_server_alias_unclashed or slave_alias == custom_domain %}
{% if slave_alias in slave_server_alias_unclashed or slave_alias == custom_domain %}
{# optionally do something about reporting back that server-alias has been unclashed #}
{# optionally do something about reporting back that server-alias has been unclashed #}
{% elif slave_alias in used_host_list %}
{% elif slave_alias in used_host_list %}
{% do slave_error_list.append('server-alias
%r
clashes' % (slave_alias,)) %}
{% do slave_error_list.append('server-alias
\'%s\'
clashes' % (slave_alias,)) %}
{% else %}
{% else %}
{% do slave_server_alias_unclashed.append(slave_alias) %}
{% do slave_server_alias_unclashed.append(slave_alias) %}
{% do used_host_list.append(slave_alias) %}
{% do used_host_list.append(slave_alias) %}
...
@@ -107,18 +107,18 @@ context =
...
@@ -107,18 +107,18 @@ context =
{% if not unauthorized_message in slave_error_list %}
{% if not unauthorized_message in slave_error_list %}
{% do slave_error_list.append(unauthorized_message) %}
{% do slave_error_list.append(unauthorized_message) %}
{% endif %}
{% endif %}
{% elif subprocess_module.call([caddy_custom_http_validator, slave[key]]) == 1 %}
{% elif subprocess_module.call([caddy_custom_http_validator,
'' ~
slave[key]]) == 1 %}
{% do slave_error_list.append('slave %s configuration invalid' % (key,)) %}
{% do slave_error_list.append('slave %s configuration invalid' % (key,)) %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %} {# for key in ['caddy_custom_http', 'caddy_custom_https', 'apache_custom_http', 'apache_custom_https'] #}
{% endfor %} {# for key in ['caddy_custom_http', 'caddy_custom_https', 'apache_custom_http', 'apache_custom_https'] #}
{% if slave.get('url') %}
{% if slave.get('url') %}
{% if subprocess_module.call([caddy_backend_url_validator, slave['url']]) == 1 %}
{% if subprocess_module.call([caddy_backend_url_validator,
'' ~
slave['url']]) == 1 %}
{% do slave_error_list.append('slave url %r invalid' % (slave['url'],)) %}
{% do slave_error_list.append('slave url %r invalid' % (slave['url'],)) %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% if slave.get('https-url') %}
{% if slave.get('https-url') %}
{% if subprocess_module.call([caddy_backend_url_validator, slave['https-url']]) == 1 %}
{% if subprocess_module.call([caddy_backend_url_validator,
'' ~
slave['https-url']]) == 1 %}
{% do slave_error_list.append('slave https-url %r invalid' % (slave['https-url'],)) %}
{% do slave_error_list.append('slave https-url %r invalid' % (slave['https-url'],)) %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
...
@@ -128,17 +128,18 @@ context =
...
@@ -128,17 +128,18 @@ context =
{% if slave.get('ssl_key') and slave.get('ssl_crt') %}
{% if slave.get('ssl_key') and slave.get('ssl_crt') %}
{% set key_popen = popen([openssl, 'rsa', '-noout', '-modulus']) %}
{% set key_popen = popen([openssl, 'rsa', '-noout', '-modulus']) %}
{% set crt_popen = popen([openssl, 'x509', '-noout', '-modulus']) %}
{% set crt_popen = popen([openssl, 'x509', '-noout', '-modulus']) %}
{% set key_modulus = key_popen.communicate(slave['ssl_key'])[0] | trim %}
{% set key_modulus = key_popen.communicate(
'' ~
slave['ssl_key'])[0] | trim %}
{% set crt_modulus = crt_popen.communicate(slave['ssl_crt'])[0] | trim %}
{% set crt_modulus = crt_popen.communicate(
'' ~
slave['ssl_crt'])[0] | trim %}
{% if not key_modulus or key_modulus != crt_modulus %}
{% if not key_modulus or key_modulus != crt_modulus %}
{% do slave_error_list.append('slave ssl_key and ssl_crt does not match') %}
{% do slave_error_list.append('slave ssl_key and ssl_crt does not match') %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% if slave.get('custom_domain') %}
{% if slave.get('custom_domain') %}
{% if slave['custom_domain'].startswith('*.') %}
{% set slave_custom_domain = '' ~ slave['custom_domain'] %}
{% set clean_custom_domain = slave['custom_domain'][2:] %}
{% if slave_custom_domain.startswith('*.') %}
{% set clean_custom_domain = slave_custom_domain[2:] %}
{% else %}
{% else %}
{% set clean_custom_domain = slave
['custom_domain']
%}
{% set clean_custom_domain = slave
_custom_domain
%}
{% endif %}
{% endif %}
{% if not validators.domain(clean_custom_domain) %}
{% if not validators.domain(clean_custom_domain) %}
{% do slave_error_list.append('custom_domain %r invalid' % (slave['custom_domain'],)) %}
{% do slave_error_list.append('custom_domain %r invalid' % (slave['custom_domain'],)) %}
...
...
software/caddy-frontend/templates/apache-custom-slave-list.cfg.in
View file @
dcafa44a
...
@@ -162,7 +162,7 @@ bytes = 8
...
@@ -162,7 +162,7 @@ bytes = 8
{# Set ssl certificates for each slave #}
{# Set ssl certificates for each slave #}
{% for cert_name in ('ssl_csr', 'ssl_proxy_ca_crt')%}
{% for cert_name in ('ssl_csr', 'ssl_proxy_ca_crt')%}
{% if
cert_name in slave_instance
%}
{% if
slave_instance.get(cert_name)
%}
{% set cert_title = '%s-%s' % (slave_reference, cert_name.replace('ssl_', '')) %}
{% set cert_title = '%s-%s' % (slave_reference, cert_name.replace('ssl_', '')) %}
{% set cert_file = '/'.join([custom_ssl_directory, cert_title.replace('-','.')]) %}
{% set cert_file = '/'.join([custom_ssl_directory, cert_title.replace('-','.')]) %}
{% do part_list.append(cert_title) %}
{% do part_list.append(cert_title) %}
...
@@ -187,7 +187,7 @@ value = {{ dumps(slave_instance.get(cert_name)) }}
...
@@ -187,7 +187,7 @@ value = {{ dumps(slave_instance.get(cert_name)) }}
{% do slave_instance.__setitem__('login_ca_crt', login_ca_crt) %}
{% do slave_instance.__setitem__('login_ca_crt', login_ca_crt) %}
{% do slave_parameter_dict.__setitem__('ssl_crt', login_certificate) %}
{% do slave_parameter_dict.__setitem__('ssl_crt', login_certificate) %}
{% do slave_parameter_dict.__setitem__('ssl_key', login_key) %}
{% do slave_parameter_dict.__setitem__('ssl_key', login_key) %}
{% if
'ssl_key' in slave_instance and 'ssl_crt' in slave_instance
%}
{% if
slave_instance.get('ssl_key') and slave_instance.get('ssl_crt')
%}
{% set cert_title = '%s-crt' % (slave_reference) %}
{% set cert_title = '%s-crt' % (slave_reference) %}
{% set key_title = '%s-key' % (slave_reference) %}
{% set key_title = '%s-key' % (slave_reference) %}
{% set cert_file = '/'.join([custom_ssl_directory, cert_title.replace('-','.')]) %}
{% set cert_file = '/'.join([custom_ssl_directory, cert_title.replace('-','.')]) %}
...
@@ -211,7 +211,7 @@ extra-context =
...
@@ -211,7 +211,7 @@ extra-context =
< = jinja2-template-base
< = jinja2-template-base
template = {{ empty_template }}
template = {{ empty_template }}
rendered = {{ cert_file }}
rendered = {{ cert_file }}
cert-content = {{ dumps(
slave_instance.get('ssl_crt') + '\n' + slave_instance.get('ssl_ca_crt',
'')) }}
cert-content = {{ dumps(
'%s\n%s' % (slave_instance.get('ssl_crt'), slave_instance.get('ssl_ca_crt', '') or
'')) }}
extra-context =
extra-context =
key content :cert-content
key content :cert-content
{% endif %}
{% endif %}
...
@@ -219,21 +219,33 @@ extra-context =
...
@@ -219,21 +219,33 @@ extra-context =
{# ########################################## #}
{# ########################################## #}
{# Set Slave Configuration #}
{# Set Slave Configuration #}
[{{ slave_configuration_section_name }}]
[{{ slave_configuration_section_name }}]
https_port = {{ dumps(https_port) }}
https_port = {{ dumps(
'' ~
https_port) }}
http_port = {{ dumps(http_port) }}
http_port = {{ dumps(
'' ~
http_port) }}
local_ipv4 = {{ dumps(local_ipv4) }}
local_ipv4 = {{ dumps(
'' ~
local_ipv4) }}
nginx_http_port = {{ dumps(nginx_http_port) }}
nginx_http_port = {{ dumps(
'' ~
nginx_http_port) }}
nginx_https_port = {{ dumps(nginx_https_port) }}
nginx_https_port = {{ dumps(
'' ~
nginx_https_port) }}
cached_port = {{ dumps(cached_port) }}
cached_port = {{ dumps(
'' ~
cached_port) }}
ssl_cached_port = {{ (ssl_cached_port) }}
ssl_cached_port = {{ (
'' ~
ssl_cached_port) }}
{# BBB: apache_custom_https and apache_custom_http #}
{# BBB: apache_custom_https and apache_custom_http #}
{% set caddy_custom_http = ((slave_instance.pop('caddy_custom_http', slave_instance.pop('apache_custom_http', ''))) % slave_parameter_dict) %}
{% set caddy_custom_http_template = slave_instance.pop('caddy_custom_http', slave_instance.pop('apache_custom_http', '')) %}
{% set caddy_custom_https = ((slave_instance.pop('caddy_custom_https', slave_instance.pop('apache_custom_https', ''))) % slave_parameter_dict) %}
{% set caddy_custom_https_template = slave_instance.pop('caddy_custom_https', slave_instance.pop('apache_custom_https', '')) %}
{% if caddy_custom_http_template is not none %}
{% set caddy_custom_http = ('' ~ caddy_custom_http_template) % slave_parameter_dict %}
caddy_custom_http = {{ dumps(caddy_custom_http) }}
caddy_custom_http = {{ dumps(caddy_custom_http) }}
{% else %}
{% set caddy_custom_http = None %}
{% endif %}
{% if caddy_custom_https_template is not none %}
{% set caddy_custom_https = ('' ~ caddy_custom_https_template) % slave_parameter_dict %}
caddy_custom_https = {{ dumps(caddy_custom_https) }}
caddy_custom_https = {{ dumps(caddy_custom_https) }}
{% else %}
{% set caddy_custom_https = None %}
{% endif %}
{{ '\n' }}
{{ '\n' }}
{% for key, value in slave_instance.iteritems() %}
{% for key, value in slave_instance.iteritems() %}
{{ key }} = {{ dumps(value) }}
{% if value is not none %}
{{ key }} = {{ dumps('' ~ value) }}
{% endif %}
{% endfor %}
{% endfor %}
[{{ slave_section_title }}]
[{{ slave_section_title }}]
...
@@ -299,7 +311,7 @@ filename = {{ monitor_ipv4_section_title }}
...
@@ -299,7 +311,7 @@ filename = {{ monitor_ipv4_section_title }}
wrapper-path = {{ promise_directory }}/${:filename}
wrapper-path = {{ promise_directory }}/${:filename}
{% endif %}
{% endif %}
{% set re6st_optimal_test = slave_instance.get('re6st-optimal-test', '') %}
{% set re6st_optimal_test =
'' ~
slave_instance.get('re6st-optimal-test', '') %}
{% set re6st_ipv6 = None %}
{% set re6st_ipv6 = None %}
{% set re6st_ipv4 = None %}
{% set re6st_ipv4 = None %}
{% if ',' in re6st_optimal_test %}
{% if ',' in re6st_optimal_test %}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment