This issue seems to be related to encoding, as I am getting the configuration rendered as expected with the below example.
My config.sls
state file:
{% set testval = ["192.168.1.11:5044", "192.168.1.12:5044"] %}
filebeat_config:
file.managed:
- name: /tmp/filebeat.yml
- source: salt://files/filebeat.yml.j2
- template: jinja
- context:
logstash_hosts: {{ testval }}
The filebeat.yml.j2
template:
hosts: {{ logstash_hosts }}
Renders:
hosts: ['192.168.1.11:5044', '192.168.1.12:5044']
However
Since the Filebeat configuration follows YAML syntax, we can use the YAML list -
syntax. We can have a filebeat.yml.j2
template file like:
output.logstash:
hosts:
{%- for host in logstash_hosts %}
- "{{ host }}"
{%- endfor %}
Using the same config.sls
state, the configuration is rendered as:
output.logstash:
hosts:
- "192.168.1.11:5044"
- "192.168.1.12:5044"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…