From bf99bfa7dc76e5e4c2281e8ead812273a2786813 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Le=20Ninivin?= <cedric.leninivin@tiolive.com>
Date: Mon, 5 Aug 2013 20:15:59 +0200
Subject: [PATCH] apache-frontend : add replicate magic with software types

---
 .../apache-frontend/instance-apache-replicate.cfg.in   | 10 ++++++++--
 software/apache-frontend/instance.cfg                  |  3 +++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/software/apache-frontend/instance-apache-replicate.cfg.in b/software/apache-frontend/instance-apache-replicate.cfg.in
index c1fd7bae2..6bb78825c 100644
--- a/software/apache-frontend/instance-apache-replicate.cfg.in
+++ b/software/apache-frontend/instance-apache-replicate.cfg.in
@@ -1,4 +1,4 @@
-{% if software_type == slap_software_type -%}
+{% if slap_software_type.startswith(software_type) -%}
 
 [jinja2-template-base]
 recipe = slapos.recipe.template:jinja2
@@ -13,7 +13,13 @@ context =
     ${:extra-context}
 
 {% set part_list = [] -%}
-{% set frontend_type = slapparameter_dict.pop('-frontend-type', 'default') -%}
+{% set type_key = 'replicate-' %}
+{% set type_key_length = type_key | length %}
+{% if slap_software_type.startswith(type_key) %}
+{%   set frontend_type = slap_software_type[type_key_length:] -%}
+{% else -%}
+{%   set frontend_type = slapparameter_dict.pop('-frontend-type', 'default') -%}
+{% endif -%}
 {% set frontend_quantity = slapparameter_dict.pop('-frontend-quantity', '2') | int -%}
 {% set slave_list_name = 'extra_slave_instance_list' -%}
 {% set frontend_list = [] %}
diff --git a/software/apache-frontend/instance.cfg b/software/apache-frontend/instance.cfg
index 519423fb1..625de0e96 100644
--- a/software/apache-frontend/instance.cfg
+++ b/software/apache-frontend/instance.cfg
@@ -33,6 +33,9 @@ recipe = slapos.cookbook:softwaretype
 default = ${template-apache-frontend:output}
 custom-personal = ${template-apache-frontend:output}
 custom-group = ${template-apache-frontend:output}
+replicate-default = $${dynamic-template-apache-replicate:rendered}
+replicate-custom-personal = $${dynamic-template-apache-replicate:rendered}
+replicate-custom-group = $${dynamic-template-apache-replicate:rendered}
 replicate = $${dynamic-template-apache-replicate:rendered}
 
 [dynamic-template-apache-replicate]
-- 
2.30.9