On 2/13/19 3:26 AM, [email protected] wrote:
Hi all,
I don't now why this task not works:
- set_fact:
my_variable: "{{ ansible_user[0 and 1] + 'gis' if
ansible_user!='wildfly' else 'wildfly' }}"
But *ansible_user[0] + ansible_user[1]* works but i want one syntaxe
shorter, exemple *ansible_user[0 and 1] *but this syntax not works !!
Why would you expect it to work? 'and' is a logical operator. Jinja2
(which is used for templating a in Ansible) uses python slicing and
substrings.
Take a look here:
https://www.journaldev.com/23774/python-string-substring
The syntax you're looking for is slicing: variable[start:end]
--
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/0b9e91bf-4cfe-f17f-f9ea-d3bf81445004%40redhat.com.
For more options, visit https://groups.google.com/d/optout.