# How to use changed\_when with user:

**URL:** <https://forum.ansible.com/t/how-to-use-changed-when-with-user/15592>\
**Category:** Ansible Developer\
**Created:** [July 2, 2014, 4:35pm UTC](https://forum.ansible.com/t/how-to-use-changed-when-with-user/15592 "2014-07-02T16:35:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenton\_Brede](https://avatars.discourse-cdn.com/v4/letter/k/db5fbb/32.png) [@Kenton\_Brede](https://forum.ansible.com/u/Kenton_Brede)\
**Post date:** [July 2, 2014, 4:35pm UTC](https://forum.ansible.com/t/how-to-use-changed-when-with-user/15592/1 "2014-07-02T16:35:17Z")

</div>

Trying to learn more about how to use Ansible. I’ve got a situation where a mix of local and LDAP users may exist on a box. In some situations user1 may either be a local user or LDAP user.

I created a task to remove certain users. The LDAP users are always marked as “changed” when obviously they aren’t. Is there a way to modify the report to say “ok?”

I know how to do this with “command:” but not “user:.”

I get “error while evaluating conditional” when using, changed\_when: “result.state != absent”

Running debug on “result” shows LDAP users have state=absent:

“item”: “user1”,  
“name”: “user1”,  
“remove”: false,  
“shell”: “/bin/bash”,  
“state”: “absent”,  
“stderr”: “userdel: error deleting password entry\nuserdel: error deleting shadow password entry\n”,

What I’d like to do is something like: not\_changed\_when: “result.state == absent”

Is there anyway to translate that into something that would work?

Thanks,  
Kent

tasks:

- name: remove users  
user: name={{ item }} state=absent  
register: result  
not\_changed\_when: “result.state != absent”  
with\_items:
- local-user1
- ldap-user1
- ldap-user2

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [July 2, 2014, 5:14pm UTC](https://forum.ansible.com/t/how-to-use-changed-when-with-user/15592/2 "2014-07-02T17:14:35Z")

</div>

​Hi Kenton,

This is the ansible-devel development list. Your question would be better  
suited on the general project list.​
