# What is search failing against getent\_group

**URL:** <https://forum.ansible.com/t/what-is-search-failing-against-getent-group/28214>\
**Category:** Ansible Project\
**Created:** [July 31, 2018, 4:19pm UTC](https://forum.ansible.com/t/what-is-search-failing-against-getent-group/28214 "2018-07-31T16:19:59Z")\
**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:** [July 31, 2018, 4:19pm UTC](https://forum.ansible.com/t/what-is-search-failing-against-getent-group/28214/1 "2018-07-31T16:19:59Z")

</div>

I must have a syntax error or don’t understand something, but the following errors out. Am I doing this wrong? or is there something special about trying to search getent\_{group,passwd}?

`

- debug:  
var: getent\_group.dba  
when: getent\_group.dba is search(“10001”)

RESULT:  
FAILED! =\> {“msg”: “The conditional check ‘getent\_group.dba is match("10001")’ failed. The error was: Unexpected templating type error occurred on ({% if getent\_group.dba is match("10000") %} True {% else %} False {% endif %}): expected string or buffer\n\nThe error appears to have been in ‘/etc/ansible/playbooks/one-offs/clean\_up\_users.yml’: line 13, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - debug:\n ^ here\n”}

CONTENT OF VAR getent\_group.dba:  
ok: [myserver] =\> {  
“getent\_group.dba”: [  
“x”,  
“10001”,  
“”  
]  
}

`

---

<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:** [July 31, 2018, 4:23pm UTC](https://forum.ansible.com/t/what-is-search-failing-against-getent-group/28214/2 "2018-07-31T16:23:16Z")

</div>

If I try the following it works, but I don’t understand why the first doesn’t work:  
`- debug:`  
`var: getent_group.dba`  
`when: getent_group.dba | lower is search("10000")`

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [July 31, 2018, 4:26pm UTC](https://forum.ansible.com/t/what-is-search-failing-against-getent-group/28214/3 "2018-07-31T16:26:05Z")

</div>

`search` operates on a string, and `getent_group.dba` is a list. Using `lower` on it is casting the list to a string.

I think you can simplify your conditional:

when: getent\_group.dba[1] == “10000”

That will directly evaluate the gid to see if it equals a certain value.

---

<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:** [July 31, 2018, 4:29pm UTC](https://forum.ansible.com/t/what-is-search-failing-against-getent-group/28214/4 "2018-07-31T16:29:15Z")

</div>

Just use this

&nbsp;&nbsp;&nbsp;when: "'10001' in getent\_group.dba"
