This is the salt config.sls
{% set testval = ["172.16.49.169:5044", "172.16.51.156:5044"] %}
filebeat_config:
file.managed:
- name: /etc/filebeat/filebeat.yml
- source: salt://filebeat/files/filebeat.yml.tmpl
- template: jinja
- user: root
- mode: 600
- context:
logstash_hosts: {{ testval }}
When rendered, the host entry looks like:
hosts: [u'172.16.49.169:5044', u'172.16.51.156:5044']
How do I remove the u' before each string?
I have tried {{ testval|tojson }}
, {{ testval|json }}
and - encoding: ascii/utf-8
The tojson
option needs to be in tmpl file, not config.sls
filebeat.yml.tmpl
output.logstash:
hosts: {{ testval|tojson }}
loadbalance: True
index: filebeat