{% set cached_server_dict = {} -%} {% set part_list = [] -%} {% set generic_instance_parameter_dict = {'cache_access': cache_access,} -%} [jinja2-template-base] recipe = slapos.recipe.template:jinja2 rendered = {{ apache_configuration_directory }}/${:filename} extra-context = context = key eggs_directory buildout:eggs-directory key develop_eggs_directory buildout:develop-eggs-directory ${:extra-context} {% for slave_instance in slave_instance_list -%} {% set slave_reference = slave_instance.get('slave_reference') -%} {% set slave_section_title = 'dynamic-template-slave-instance-%s' % slave_reference -%} {% set slave_parameter_dict = generic_instance_parameter_dict.copy() -%} {% if slave_instance.get('server_name', None) == None -%} {% do slave_instance.__setitem__('server_name', "%s.%s" % (slave_instance.get('slave_reference').replace("-", "").lower(), domain)) -%} {% endif -%} {% if 'enable_cache' in slave_instance -%} # The slave use cache {% do cached_server_dict.__setitem__(slave_instance.get('server_name'), slave_instance.get('url')) -%} {% endif -%} {% do slave_instance.__setitem__('url', cache_access) -%} {% do part_list.append(slave_section_title) -%} [{{ slave_section_title }}] < = jinja2-template-base template = {{ template_slave_configuration }} filename = {{ '%s.conf' % slave_reference }} extensions = jinja2.ext.do extra-context = section slave_parameter {{ 'slave-instance-%s-configuration' % slave_reference }} raw domain {{ domain }} raw https_port {{ https_port }} raw http_port {{ http_port }} {{ '\n' }} # Set apache configuration for slave [{{ ('slave-instance-%s-configuration' % slave_reference) }}] {% for key, value in slave_instance.iteritems() -%} {{ key }} = {{ dumps(value) }} {% endfor %} {% endfor -%} {% do part_list.append('cached-rewrite-rules') -%} [cached-rewrite-rules] < = jinja2-template-base template = {{ template_rewrite_cached }} rendered = {{ rewrite_cached_configuration }} extra-context = import json_module json key server_dict rewrite-rules:rules [rewrite-rules] rules = {{ dumps(cached_server_dict) }} [buildout] parts += {% for part in part_list -%} {{ ' %s' % part }} {% endfor -%} eggs-directory = {{ eggs_directory }} develop-eggs-directory = {{ develop_eggs_directory }} offline = true cache-access = {{ cache_access }}