# user module bug?

**URL:** <https://forum.ansible.com/t/user-module-bug/12061>\
**Category:** Ansible Project\
**Created:** [November 1, 2012, 3:37pm UTC](https://forum.ansible.com/t/user-module-bug/12061 "2012-11-01T15:37:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [November 1, 2012, 3:37pm UTC](https://forum.ansible.com/t/user-module-bug/12061/1 "2012-11-01T15:37:04Z")

</div>

I think there are two different bugs in the user module.

1.) If I leave the “authorized\_key” action in the tasks, the user will not be deleted even when the state=absent for the user module.

2.) When I comment out the “authorized\_key” action for that user, the user module returns this error:  
“failed: [[benelec.net](http://benelec.net)] =\> {“failed”: true, “msg”: “userdel: warning: can’t remove /var/mail/harm: No such file or directory\n”, “name”: “harm”, “rc”: 12}”

And the action: “action: user force=yes remove=yes name=harm state=absent”

A second run is then ok, as the user is gone.

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [November 1, 2012, 3:46pm UTC](https://forum.ansible.com/t/user-module-bug/12061/2 "2012-11-01T15:46:53Z")

</div>

As for number 1.)  
I had this:

- name: Users beheren  
action: user comment=Harm groups=sudo append=yes password=XXXXXforce=yes remove=yes name=harm state=absent  
action: authorized\_key user=harm key=‘’

Which does not work, but this does work:

- name: Users beheren  
action: user comment=Harm groups=sudo append=yes password=beQCZAKpGdV0w force=yes remove=yes name=harm state=absent
- name: Add key  
action: authorized\_key user=harm key=‘’

At least then the user get’s deleted and you get a reminder you still have an action for a authorized\_key in your playbook for that user 😉

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [November 1, 2012, 3:54pm UTC](https://forum.ansible.com/t/user-module-bug/12061/3 "2012-11-01T15:54:38Z")

</div>

Please show me a full example

– Michael

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [November 1, 2012, 3:55pm UTC](https://forum.ansible.com/t/user-module-bug/12061/4 "2012-11-01T15:55:13Z")

</div>

Ok please define what doesn’t work means

– Michael

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [November 1, 2012, 3:58pm UTC](https://forum.ansible.com/t/user-module-bug/12061/5 "2012-11-01T15:58:56Z")

</div>

The full original version:

---

<div class="post-metadata">

**Author:** ![Stephen\_Fromm](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@Stephen\_Fromm](https://forum.ansible.com/u/Stephen_Fromm)\
**Post date:** [November 1, 2012, 4:37pm UTC](https://forum.ansible.com/t/user-module-bug/12061/6 "2012-11-01T16:37:38Z")

</div>

There’s a couple issues here. See inline below.

> The full original version:
> 
> * * *
> 
> - hosts: all  
> vars:  
> user: mark  
> sudo: true  
> gather\_facts: false  
> tasks:
> - name: Users beheren  
> action: user comment=Harm groups=sudo append=yes password=XXXXXX force=yes remove=yes name=harm state=absent  
> action: authorized\_key user=harm key=‘’

The above play has a problem. You have two actions defined in one task. It should be one action per task.

> This did not delete the user. But this one:
> 
> * * *
> 
> - hosts: all  
> vars:  
> user: mark  
> sudo: true  
> gather\_facts: false  
> tasks:
> - name: Users beheren  
> action: user comment=Harm groups=sudo append=yes password=XXXX force=yes remove=yes name=harm state=absent
> - name: Key toevoegen  
> action: authorized\_key user=harm key=‘’
> 
> Does, but just gives two warnings, one that the /var/mail/harm file could not be found and the other that the user could not be found anymore (As I just deleted it)

Is this on debian or ubuntu? I recall an issue with userdel on a version of one of those distributions where userdel would successfully delete the user but exit with rc != 0 because /var/mail/user didn’t exist. Please let us know the distribution and version.

sf

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [November 1, 2012, 4:59pm UTC](https://forum.ansible.com/t/user-module-bug/12061/7 "2012-11-01T16:59:48Z")

</div>

> There’s a couple issues here. See inline below.
> 
> > The full original version:  
> > tasks:
> > 
> > - name: Users beheren  
> > action: user comment=Harm groups=sudo append=yes password=XXXXXX force=yes remove=yes name=harm state=absent  
> > action: authorized\_key user=harm key=‘’
> 
> The above play has a problem. You have two actions defined in one task. It should be one action per task.

Noted. Wont’ do it again.

> two warnings, one that the /var/mail/harm file could not be found and the other that the user could not be found anymore (As I just deleted it)
> 
> Is this on debian or ubuntu? I recall an issue with userdel on a version of one of those distributions where userdel would successfully delete the user but exit with rc != 0 because /var/mail/user didn’t exist. Please let us know the distribution and version.

Versions:  
[data.xxxx.net](http://data.xxxx.net) | success | rc=0 \>\>  
Debian GNU/Linux 6.0 \n \l

[zimbra.xxxx.net](http://zimbra.xxxx.net) | success | rc=0 \>\>  
Ubuntu 12.04.1 LTS \n \l

And the uname:

[data.xxxx.net](http://data.xxxx.net) | success | rc=0 \>\>  
Linux data 2.6.32-14-pve #1 SMP Tue Aug 21 08:24:37 CEST 2012 i686 GNU/Linux

[zimbra.xxxx.net](http://zimbra.xxxx.net) | success | rc=0 \>\>  
Linux zimbra 3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012 x86\_64 x86\_64 x86\_64 GNU/Linux

Mark

---

<div class="post-metadata">

**Author:** ![Stephen\_Fromm](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@Stephen\_Fromm](https://forum.ansible.com/u/Stephen_Fromm)\
**Post date:** [November 2, 2012, 6:32am UTC](https://forum.ansible.com/t/user-module-bug/12061/8 "2012-11-02T06:32:47Z")

</div>

See [https://bugs.launchpad.net/ubuntu/+source/shadow/+bug/1023509](https://bugs.launchpad.net/ubuntu/+source/shadow/+bug/1023509). You may want to test the behavior of userdel on those platforms and evaluate whether the fix is applied and working.

Also, I didn’t see the output from ansible-playbook in this thread. You said it works, but gives warnings. Please provide specific output.

sf

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [November 2, 2012, 6:51am UTC](https://forum.ansible.com/t/user-module-bug/12061/9 "2012-11-02T06:51:42Z")

</div>

> See [https://bugs.launchpad.net/ubuntu/+source/shadow/+bug/1023509](https://bugs.launchpad.net/ubuntu/+source/shadow/+bug/1023509). You may want to test the behavior of userdel on those platforms and evaluate whether the fix is applied and working.

Strange, as it happens on both a Debian 6.0.6 and a Ubuntu 12.04 platform

> Also, I didn’t see the output from ansible-playbook in this thread. You said it works, but gives warnings. Please provide specific output.

The first post has it:

2.) When I comment out the “authorized\_key” action for that user, the user module returns this error:  
“failed: [[benelec.net](http://benelec.net/)] =\> {“failed”: true, “msg”: “userdel: warning: can’t remove /var/mail/harm: No such file or directory\n”, “name”: “harm”, “rc”: 12}”

But the full thing looks like this:

> mark@xxxx:~/ansible/xxxx$ ansible-playbook -c ssh -K ./harm.yml  
> sudo password:
> 
> PLAY [xxxx] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
> 
> TASK: [Users beheren] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> failed: [[xxxx.net](http://xxxx.net)] =\> {“failed”: true, “msg”: “userdel: warning: can’t remove /var/mail/harm: No such file or directory\n”, “name”: “harm”, “rc”: 12}  
> failed: [[data.xxxx.net](http://data.xxxx.net)] =\> {“failed”: true, “msg”: “userdel: warning: can’t remove /var/mail/harm: No such file or directory\n”, “name”: “harm”, “rc”: 12}  
> failed: [[tools.xxxx.net](http://tools.xxxx.net)] =\> {“failed”: true, “msg”: “userdel: warning: can’t remove /var/mail/harm: No such file or directory\n”, “name”: “harm”, “rc”: 12}  
> failed: [[www.xxxx.net](http://www.xxxx.net)] =\> {“failed”: true, “msg”: “userdel: warning: can’t remove /var/mail/harm: No such file or directory\n”, “name”: “harm”, “rc”: 12}  
> failed: [[zimbra.xxxx.net](http://zimbra.xxxx.net)] =\> {“failed”: true, “msg”: “userdel: warning: can’t remove /var/mail/harm: No such file or directory\n”, “name”: “harm”, “rc”: 12}
> 
> FATAL: all hosts have already failed – aborting
> 
> PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> [xxxx.net](http://xxxx.net) : ok=0 changed=0 unreachable=0 failed=1  
> [data.xxxx.net](http://data.xxxx.net) : ok=0 changed=0 unreachable=0 failed=1  
> [tools.xxxx.net](http://tools.xxxx.net) : ok=0 changed=0 unreachable=0 failed=1  
> [www.xxxx.net](http://www.xxxx.net) : ok=0 changed=0 unreachable=0 failed=1  
> [zimbra.xxxx.net](http://zimbra.xxxx.net) : ok=0 changed=0 unreachable=0 failed=1

And the yaml file:

> mark@xxxxxx:~/ansible/xxxxxx$ cat ./harm.yml
> 
> * * *
> 
> - hosts: xxxxxx
> 
> vars:
> 
> user: mark
> 
> sudo: true
> 
> gather\_facts: false
> 
> tasks:
> 
> - name: Users beheren
> 
> action: user comment=Harm groups=sudo append=yes password=xxxxxx force=yes remove=yes name=harm state=absent

And finally the hosts in question:

> mark@xxxxxx:~/ansible/xxxxxx$ ansible xxxxxx -c ssh -m command -a “cat /etc/issue”
> 
> [xxxxxx.net](http://xxxxxx.net) | success | rc=0 \>\>
> 
> Debian GNU/Linux 6.0 \n \l
> 
> [data.xxxxxx.net](http://data.xxxxxx.net) | success | rc=0 \>\>
> 
> Debian GNU/Linux 6.0 \n \l
> 
> [tools.xxxxxx.net](http://tools.xxxxxx.net) | success | rc=0 \>\>
> 
> Debian GNU/Linux 6.0 \n \l
> 
> [www.xxxxxx.net](http://www.xxxxxx.net) | success | rc=0 \>\>
> 
> Debian GNU/Linux 6.0 \n \l
> 
> [zimbra.xxxxxx.net](http://zimbra.xxxxxx.net) | success | rc=0 \>\>
> 
> Ubuntu 12.04.1 LTS \n \l

Thanks,  
Mark

---

<div class="post-metadata">

**Author:** ![Stephen\_Fromm](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@Stephen\_Fromm](https://forum.ansible.com/u/Stephen_Fromm)\
**Post date:** [November 2, 2012, 5:53pm UTC](https://forum.ansible.com/t/user-module-bug/12061/10 "2012-11-02T17:53:05Z")

</div>

Disclaimer: i’m not a Debian/Ubuntu user.

Ubuntu gets the package from Debian. The launchpad bug page has a link to Debian’s bug tracker for the same issue. Debian’s bug tracker reports the issue is fixed in 1:4.1.5-1. For Debian, this version is available in testing. It appears to not yet be available in stable. As I understand, Ubuntu bases their passwd package on Debian’s. I poked at Ubuntu’s package database and it isn’t clear to me when they plan to land 1:4.1.5-1. Since this is acknowledged by upstream as a bug, I encourage you to apply the fix available from them.

sf
