Commit 10415aa8 authored by Nicolas Wavrant's avatar Nicolas Wavrant

slaprunner: parameters can be sent to the instance deployed inside the webrunner

parent 2ba26309
......@@ -53,6 +53,16 @@ The parameter "auto-deploy-instance" can be explicitly set to allow or prevent t
There also exists the parameter "autorun", which will build&run your software if set to true. For this, you need "auto_deploy" to true, and set the parameter "slapos-software" to the software you want to deploy. Do not hesitate to clone a different repo than "slapos", or to change the tag/branch to use your custom Software Release. (see "slapos-repository" and "slapos-reference" in previous section).
To deploy the instance with some parameters, just give to the runner parameters starting with "parameter-", they will be correctly forwarded to the instance, which will use them for its configuration. For example, if you want to send to the sofware helloworld the parameter "name" with the value "nicolas", here is how to configure the parameter.xml of the webrunner for auto-depolyment :
<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="slapos-software">software/helloworld</parameter>
<parameter id="auto_deploy">true</parameter>
<parameter id="autorun">true</parameter>
<parameter id="parameter-name">nicolas</parameter>
</instance>
Resilience :
------------
......
......@@ -111,6 +111,15 @@ filename = slapos.cfg.in
download-only = true
mode = 0644
[parameters-template]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/${:filename}
#md5sum = 8207e74c7b97a4a3f3be390ea4f97ae1
location = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = parameters.xml.in
download-only = true
mode = 0644
[eggs]
recipe = z3c.recipe.scripts
eggs =
......
......@@ -26,6 +26,7 @@ parts +=
slapos-repo-config
cron-entry-backup
cron-entry-prepare-software
deploy-instance-parameters
###Parts to add for monitoring
slap-parameters
certificate-authority
......
......@@ -23,6 +23,7 @@ parts +=
slapos-cfg
slapos-repo-config
cron-entry-prepare-software
deploy-instance-parameters
# have to repeat the next one, as it's not inherited from pbsready-import
import-on-notification
###Parts to add for monitoring
......
......@@ -22,6 +22,7 @@ parts =
slapos-cfg
slapos-repo-config
cron-entry-prepare-software
deploy-instance-parameters
{% if slapparameter_dict.get('custom-frontend-backend-url') %}
custom-frontend-promise
{% endif %}
......@@ -541,6 +542,29 @@ name = prepare-software
frequency = */2 * * * *
command = $${prepare-software:wrapper-path}
[instance-parameters]
recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
template = ${parameters-template:location}/${parameters-template:filename}
rendered = $${directory:etc}/.parameter.xml.default
mode = 0644
context =
key slapparameter_dict slap-configuration:configuration
[deploy-instance-parameters]
recipe = plone.recipe.command
stop-on-error = true
parameter-xml = $${directory:etc}/.parameter.xml
command = if [ ! -f $${:parameter-xml} ]; then cp $${instance-parameters:rendered} $${:parameter-xml}; fi
[slap-configuration]
recipe = slapos.cookbook:slapconfiguration.serialised
computer = $${slap-connection:computer-id}
partition = $${slap-connection:partition-id}
url = $${slap-connection:server-url}
key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file}
[public]
shell-password = $${shellinabox-code:passwd}
......
{% set inst_parameter_dict = {} -%}
{% if slapparameter_dict is defined -%}
{% for key in slapparameter_dict.keys() -%}
{% if key.startswith('parameter-') -%}
{% do inst_parameter_dict.__setitem__(key[10:], slapparameter_dict.pop(key)) -%}
{% endif -%}
{% endfor -%}
{% endif -%}
<?xml version='1.0' encoding='utf-8'?>
<instance>
{% if slapparameter_dict is defined %}
{% for parameter_name in inst_parameter_dict.keys() %}
<parameter id="{{ parameter_name }}">{{ inst_parameter_dict[parameter_name] }}</parameter>
{% endfor %}
{% endif %}
</instance>
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