# jinja help

**URL:** <https://forum.ansible.com/t/jinja-help/26722>\
**Category:** Ansible Project\
**Created:** [February 13, 2018, 7:01pm UTC](https://forum.ansible.com/t/jinja-help/26722 "2018-02-13T19:01:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [February 13, 2018, 7:01pm UTC](https://forum.ansible.com/t/jinja-help/26722/1 "2018-02-13T19:01:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Jason3](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@Jason3](https://forum.ansible.com/u/Jason3)\
**Post date:** [February 13, 2018, 8:25pm UTC](https://forum.ansible.com/t/jinja-help/26722/2 "2018-02-13T20:25:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [February 13, 2018, 8:27pm UTC](https://forum.ansible.com/t/jinja-help/26722/3 "2018-02-13T20:27:49Z")

</div>

Thanks Jason. I also found that this works too:

`when: not(ansible_hostname | lower | search ("sql-db"))`

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [February 13, 2018, 9:23pm UTC](https://forum.ansible.com/t/jinja-help/26722/4 "2018-02-13T21:23:34Z")

</div>

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