instance-resilient.cfg.jinja2 3.59 KB
Newer Older
1 2
# vim: set ft=cfg:

3 4 5 6 7
# Default parameters
# NOTE: in case of resilient instance, auto-deploy-instance
# set to false (else it could be dangerous)
{% do slapparameter_dict.__setitem__('auto-deploy', slapparameter_dict.get('auto-deploy', 'true')) %}
{% do slapparameter_dict.__setitem__('auto-deploy-instance', slapparameter_dict.get('auto-deploy-instance', 'false')) %}
8
# let decide the number of clones we want. We can't have more than 2 clones
9
{% set number_of_instances = slapparameter_dict.get('resilient-clone-number', 1)|int %}
10 11
{% if number_of_instances > 2 %}
  {% set number_of_instances = 2 %}
12
{% endif %}
13
{% set monitor_return = ['monitor-base-url', 'monitor-url', 'monitor-user', 'monitor-password'] -%}
14
{% set monitor_parameter = {'monitor-cors-domains': slapparameter_dict.pop('monitor-cors-domains', "monitor.app.officejs.com")} -%}
15
{% set monitor_dict = {'parameter': monitor_parameter, 'return': monitor_return, 'set-monitor-url': True} -%}
16
{% set monitor_interface_url = slapparameter_dict.pop('monitor-interface-url', 'https://monitor.app.officejs.com') -%}
17

18 19 20 21 22 23 24 25 26 27
{% import 'parts' as parts %}
{% import 'replicated' as replicated %}

[buildout]
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
offline = true

# += because we need to take up parts (like instance-custom, slapmonitor etc) from the profile we extended
parts +=
28
  {{ parts.replicate("runner", number_of_instances + 1) }}
29
  publish-connection-information
30

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
[monitor-htpasswd]
recipe = slapos.cookbook:generate.password
storage-path = ${directory:etc}/.monitor_user
bytes = 8
username = admin

{%  do monitor_parameter.__setitem__('monitor-username', slapparameter_dict.get('monitor-username', 'admin'))%}
{%  do monitor_parameter.__setitem__('monitor-password', slapparameter_dict.get('monitor-password', '${monitor-htpasswd:passwd}'))%}

{{ replicated.replicate("runner", number_of_instances + 1, "runner-export", "runner-import", slapparameter_dict=slapparameter_dict, monitor_parameter_dict=monitor_dict) }}

[directory]
recipe = slapos.cookbook:mkdirectory
etc = ${buildout:directory}/etc

46 47 48

# Bubble up the parameters
[request-runner]
49
return = url ssh-public-key ssh-url notification-id ip backend_url url ssh_command access_url 1_info 2_info webdav_url public_url git_public_url git_private_url {{ monitor_return | join(' ') }}
50

51
[publish-connection-information]
52
recipe = slapos.cookbook:publish
53
1_info = ${request-runner:connection-1_info}
54
2_info = ${request-runner:connection-2_info}
55
backend_url = ${request-runner:connection-backend_url}
56
access_url = ${request-runner:connection-access_url}
57 58
url = ${request-runner:connection-url}
ssh_command = ${request-runner:connection-ssh_command}
59
webdav_url = ${request-runner:connection-webdav_url}
60
public_url = ${request-runner:connection-public_url}
61 62
git_public_url = ${request-runner:connection-git_public_url}
git_private_url = ${request-runner:connection-git_private_url}
63 64 65 66 67 68
{% for key in monitor_return -%}
{{ key }} = ${request-runner:connection-{{ key }}}
{% endfor -%}
{% if monitor_interface_url -%}
monitor_setup_url = {{ monitor_interface_url }}/#page=settings_configurator&url=${request-runner:connection-monitor-url}
{% endif -%}
69 70 71 72 73

[slap-parameter]
# Default parameters for distributed deployment
# I.e state "backup1 of maria should go there, ..."
# XXX-Cedric: Hardcoded number of backups. Should be dynamically generated.
74 75 76 77
{% for nb in range(1,number_of_instances+1) %}
runner{{nb}}-computer-guid =
pbs-runner{{nb}}-computer-guid =
{% endfor %}
78 79 80 81
# XXX-Cedric: Hardcoded parameters. Should be dynamically generated.
domain =
authorized-key =
instance-amount = 10
82
debug = false
83
resilient-clone-number = 1