I have this jinja2 going on in a play:
with_items: "{% for host in play_hosts -%}
{% if (host != inventory_hostname) -%}
{{host}} slave
{% endif -%}
{% endfor -%}"
which basically appends some lines to a file with a line break, e.g.
line1
line2
This is working how I need, however my OCD wants to get rid of the blank
line in the script.
If I try this (note the minus sign infront of "endif" and the \n after
"slave"
with_items: "{% for host in play_hosts -%}
{% if (host != inventory_hostname) -%}
{{host}} slave\n
{%- endif -%}
{% endfor -%}"
the new line is deleted and the hosts are printed in line with no spacing.
e.g.
line1line2
If I leave in the \n but remove the minus infront of endif, I end up with
line1
line2
(note the indent)
It also works if I have it all in one line but its hard to read, and I
don't want to template the file.
Is there a trick to format this correctly or should I just suck it up?
--
------------------------------
The contents of this email are confidential and may be subject to legal or
professional privilege and copyright. No representation is made that this
email is free of viruses or other defects. If you have received this
communication in error, you may not copy or distribute any part of it or
otherwise disclose its contents to anyone. Please advise the sender of your
incorrect receipt of this correspondence.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/357712bd-bece-42f5-8daf-560b20c7842c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.