On 16.06.2019 13:21, Ansar Sahit wrote:
Hi All,
Thankyou for the response, I used Rigler's set_fact to determine the
hostgroup like below
- name: Set Group
set_fact:
group: |
{% if c == 1 %}
grp1
{% elif c ==2 %}
grp3
{% else %}
grp4
{% endif %}
My hunch is that this produce a new line at the end.
You can check with
- debug: var=group
So when using YAML multi line you need to control the newlines.
|- will remove the last newline and {%- will remove any newline produced
by the YAML multiple lines
- name: Set Group
set_fact:
group: |-
{% if c == 1 %}
grp1
{%- elif c ==2 %}
grp3
{%- else %}
grp4
{%- endif %}
Im getting below error.
[WARNING]: **Could not match supplied host pattern, ignoring: grp1**
It's probably a newline at the end.
--
Kai Stian Olstad
--
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/61028d51315a2b48d7a178bc0b79aff7%40olstad.com.
For more options, visit https://groups.google.com/d/optout.