Приветствую всех.
Есть список значений:
services:
- name: es
dirs:
- { type: "es_script", path: "/opt/distrib/efk/script", user: "elasticsearch", group: "elasticsearch", mode: '0765' }
- { type: "es_config", path: "/etc/elasticsearch", user: "elasticsearch", group: "elasticsearch", mode: '0765' }
- { type: es_data, path: /opt/data/elasticsearch, user: elasticsearch, group: elasticsearch, mode: '0765' }
- { type: es_log, path: /opt/log/elasticsearch, user: elasticsearch, group: elasticsearch, mode: '0765' }
Хочется по ключу type при помощи j2 выдёргивать другие значения строки path,usr.
Примерно пытаюсь так:
- name: Set the l_env
set_fact:
l_env: "{% for tmp in service.dirs %}{% if tmp.type == 'es_script' %}{% set t_env = tmp.path %}{{- t_env }}{% endif %}{%- endfor %}"
- name: Ensure Systemd unit file is present.
template:
src: jinja2.j2
dest: "{{ l_env }}"