diff --git a/salt/elasticsearch/template.map.jinja b/salt/elasticsearch/template.map.jinja index 72be1ec58..c460f4ab1 100644 --- a/salt/elasticsearch/template.map.jinja +++ b/salt/elasticsearch/template.map.jinja @@ -109,9 +109,15 @@ {% if not settings.get('index_sorting', False) | to_bool and settings.index_template.template.settings.index.sort is defined %} {% do settings.index_template.template.settings.index.pop('sort') %} {% endif %} -{% if DATA_RETENTION_METHOD == 'DLM' and settings.index_template.data_stream is defined and settings.data_stream_lifecycle is defined %} -{% if settings.data_stream_lifecycle.data_retention is defined and settings.data_stream_lifecycle.data_retention %} -{% do settings.index_template.template.update({'lifecycle': {'data_retention': settings.data_stream_lifecycle.data_retention}}) %} +{% if DATA_RETENTION_METHOD == 'DLM' and settings.index_template.data_stream is defined %} +{# Addon defaults are generated without data_stream_lifecycle, so fall back to global defaults. #} +{% if settings.data_stream_lifecycle is defined %} +{% set DATA_STREAM_LIFECYCLE = settings.data_stream_lifecycle %} +{% else %} +{% set DATA_STREAM_LIFECYCLE = DEFAULT_GLOBAL_OVERRIDES.data_stream_lifecycle %} +{% endif %} +{% if DATA_STREAM_LIFECYCLE.data_retention is defined and DATA_STREAM_LIFECYCLE.data_retention %} +{% do settings.index_template.template.update({'lifecycle': {'data_retention': DATA_STREAM_LIFECYCLE.data_retention}}) %} {% else %} {% do settings.index_template.template.update({'lifecycle': {}}) %} {% endif %}