'Replace placeholders in a template with the proper values.
Return a tuple made of `init_config` and `instances`.'

def _render_template(self, init_config_tpl, instance_tpl, variables):

    config = (init_config_tpl, instance_tpl)
    for tpl in config:
        for key in tpl:
            for var in self.PLACEHOLDER_REGEX.findall(str(tpl[key])):
                var_value = variables.get(var.strip('%'))
                if (var_value is not None):
                    if isinstance(tpl[key], list):
                        if isinstance(var_value, list):
                            tpl[key].remove(var)
                            tpl[key] += var_value
                            tpl[key] = list(set(tpl[key]))
                        else:
                            for (idx, val) in enumerate(tpl[key]):
                                tpl[key][idx] = val.replace(var, var_value)
                    elif isinstance(var_value, list):
                        tpl[key] = var_value
                    else:
                        tpl[key] = tpl[key].replace(var, var_value)
                else:
                    log.warning('Failed    to    interpolate    variable    {0}    for    the    {1}    parameter.    Dropping    this    configuration.'.format(var, key))
                    return None
    return config
