Commit a4dd8a5f authored by Vincent Pelletier's avatar Vincent Pelletier

stack.erp5: Add support for HOSTALIAS.

hosts-dict alone is not powerful enough: in some cases, we want to alias a
foreign hostname in order to control access to it (ex: to make interface
calls fail on a clone).
parent 943f8de1
......@@ -50,8 +50,19 @@
"uniqueItems": true,
"type": "array"
},
"hostalias-dict": {
"description": "Hostname-to-hostname mapping",
"default": {},
"patternProperties": {
".*": {
"description": "A hostname to which current entry will resolve",
"type": "string"
}
},
"type": "object"
},
"hosts-dict": {
"description": "Host entries to be used in addition to and/or overriding auto-generated ones",
"description": "Hostname-to-IP mapping",
"default": {
"erp5-catalog-0": "some-ip",
"erp5-catalog-...": "some-ip",
......
......@@ -197,7 +197,7 @@ md5sum = 0bf51218ecbf2bd319214192448a3ef7
[template-runzope-userhosts-preloaded]
< = download-base
filename = runzope_userhosts_preloaded.in
md5sum = 19fc529e34e764c73fcf5f56aee0db56
md5sum = bc6048b85b410693e60e5a77399dd1b7
[template-my-cnf]
< = download-base
......@@ -296,7 +296,7 @@ extra-context =
[template-erp5]
< = download-base
filename = instance-erp5.cfg.in
md5sum = 28db329061ae863367a76951b9b1152c
md5sum = 7e7558117b7a6b6e4e51427681d0d8b7
[template-zeo]
< = download-base
......@@ -306,7 +306,7 @@ md5sum = cc91f5a4778153dc1d34398b9a80150d
[template-zope]
< = download-base
filename = instance-zope.cfg.in
md5sum = 129b0468957dec95c0c04c3484df8624
md5sum = add782ce842fded926264c42f3060f3c
link-binary =
${aspell:location}/bin/aspell
${coreutils:location}/bin/basename
......
......@@ -91,12 +91,14 @@ recipe = slapos.cookbook:generate.password
return =
zope-address-list
hosts-dict
hostalias-dict
config-bt5 = {{ dumps(slapparameter_dict.get('bt5', 'erp5_full_text_myisam_catalog erp5_configurator_standard erp5_configurator_maxma_demo erp5_configurator_ung erp5_configurator_run_my_doc')) }}
config-bt5-repository-url = {{ dumps(slapparameter_dict.get('bt5-repository-url', local_bt5_repository)) }}
config-cloudooo-url = ${request-cloudooo:connection-url}
config-deadlock-debugger-password = ${deadlock-debugger-password:passwd}
config-developer-list = {{ dumps(slapparameter_dict.get('developer-list', [inituser_login])) }}
config-hosts-dict = {{ dumps(slapparameter_dict.get('hosts-dict', {})) }}
config-hostalias-dict = {{ dumps(slapparameter_dict.get('hostalias-dict', {})) }}
config-inituser-login = {{ dumps(inituser_login) }}
config-inituser-password = ${inituser-password:passwd}
config-kumofs-url = ${request-memcached-persistent:connection-url}
......
......@@ -127,8 +127,28 @@ ipv6 = {{ ipv6 }}
) -%}
{%- endfor %}
{% do hosts_dict.update(slapparameter_dict['hosts-dict']) -%}
[host-common]
[hosts-parameter]
# Used for both hosts and hostaliases sections.
host-dict = {{ dumps(hosts_dict) }}
hostalias-dict = {{ dumps(slapparameter_dict['hostalias-dict']) }}
# Note: there is a subtle difference between hosts and hostaliases files:
# - hosts files start with resolved, followed by alias(es) (only one alias per
# line in this case)
# - hostaliases start with alias, followed by resolved
# ...so it's not possible to merge these templates (not a big deal anyway).
[hostaliases]
recipe = slapos.recipe.template:jinja2
template = inline: {{ '
{% for alias, aliased in host_dict.items() -%}
{{ alias }} {{ aliased }}
{% endfor %}
' }}
rendered = ${directory:etc}/hostaliases
context = key host_dict hosts-parameter:hostalias-dict
[hosts]
recipe = slapos.recipe.template:jinja2
......@@ -145,6 +165,7 @@ runzope-binary = {{ bin_directory }}/runzope
userhosts = {{ parameter_dict['userhosts'] }}
shell-path = {{ parameter_dict['dash'] }}/bin/dash
hosts = ${hosts:rendered}
hostaliases = ${hostaliases:rendered}
[preload-userhosts-runzope]
recipe = slapos.recipe.template:jinja2
......
#!{{ parameter_dict['shell-path'] }}
HOSTS='{{ parameter_dict['hosts'] }}' exec '{{ parameter_dict['userhosts'] }}' '{{ parameter_dict['runzope-binary'] }}' "$@"
HOSTALIASES='{{ parameter_dict['hostaliases'] }}' HOSTS='{{ parameter_dict['hosts'] }}' exec '{{ parameter_dict['userhosts'] }}' '{{ parameter_dict['runzope-binary'] }}' "$@"
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