jinja help

13 views
Skip to first unread message

John Harmon

unread,
Feb 13, 2018, 2:01:05 PM2/13/18
to Ansible Project
I need to take this and do the opposite:
when: ansible_hostname | lower | search ("sql-db")

ie: when: not(ansible_hostname | lower | search ("ebs-db"))

Is there a good place to find out what I can/can't do for this kind of stuff (maybe even just a cheat sheet)?  I don't know anything about jinja and don't know the best place to start.  Also, how would you change the above to exclude "sql-db" when in the ansible_hostname fact?

Jason Gilfoil

unread,
Feb 13, 2018, 3:25:37 PM2/13/18
to Ansible Project
Not sure about your second question, but as for your first, this should work.

when: ansible_hostname | lower | search ("sql-db") == False

No idea where I found it originally, i just dug through my own scripts for an example.

John Harmon

unread,
Feb 13, 2018, 3:27:50 PM2/13/18
to Ansible Project
Thanks Jason.  I also found that this works too:
when: not(ansible_hostname | lower | search ("sql-db"))

Kai Stian Olstad

unread,
Feb 13, 2018, 4:23:59 PM2/13/18
to ansible...@googlegroups.com
On Tuesday, 13 February 2018 20.01.05 CET John Harmon wrote:
> Is there a good place to find out what I can/can't do for this kind of
> stuff (maybe even just a cheat sheet)? I don't know anything about jinja
> and don't know the best place to start. Also, how would you change the
> above to exclude "sql-db" when in the ansible_hostname fact?

The Jinja template documentation is always a good start/read
http://jinja.pocoo.org/docs/2.10/templates/

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages