user-module shows changed for user after reboot.

Hi,

I’m hitting a strange problem on a freshly installed Ubuntu 14.04 box. There’s a user named “irc” by default.
When I alter the user with the following playbook, the run shows ‘changed’. A subsequent run does not show “changed” so idempotency works here.
However after restarting the server and running the playbook again, it shows again as changed. But I cannot see any changed in /etc/passwd or /etc/shadow and the user isn’t even changed with the task.

`

  • hosts: localhost
    tasks:
  • name: test
    user: name=‘irc’
    `

Here’s the output of the playbook:

`
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-25-generic x86_64)

  • Documentation: https://help.ubuntu.com/
    Last login: Mon Jan 25 19:59:24 2016 from 127.0.0.1
    vagrant@vagrant:~$ ansible-playbook --sudo -i hosts default.yml -vvvv
    Using /etc/ansible/ansible.cfg as config file
    Loaded callback default of type stdout, v2.0
    1 plays in default.yml

PLAY ***************************************************************************

TASK [setup] *******************************************************************
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 ‘( umask 22 && mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1453751994.23-142922896848096 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1453751994.23-142922896848096 )” )’
<127.0.0.1> PUT /tmp/tmpopyDE_ TO /home/vagrant/.ansible/tmp/ansible-tmp-1453751994.23-142922896848096/setup
<127.0.0.1> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r ‘[127.0.0.1]’
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 ‘/bin/sh -c ‘"’“'sudo -H -S -n -u root /bin/sh -c '”’“'”‘"’“'”‘"’“‘echo BECOME-SUCCESS-lmpcvnjvveqajnfbptwgmmoxcksxvmyc; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1453751994.23-142922896848096/setup; rm -rf “/home/vagrant/.ansible/tmp/ansible-tmp-1453751994.23-142922896848096/” > /dev/null 2>&1’”‘"’“'”‘"’“'”‘"’‘"’"‘’
ok: [127.0.0.1]

TASK [test] ********************************************************************
task path: /home/vagrant/default.yml:3
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 ‘( umask 22 && mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1453751994.86-84090426534284 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1453751994.86-84090426534284 )” )’
<127.0.0.1> PUT /tmp/tmp7N6epS TO /home/vagrant/.ansible/tmp/ansible-tmp-1453751994.86-84090426534284/user
<127.0.0.1> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r ‘[127.0.0.1]’
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 ‘/bin/sh -c ‘"’“'sudo -H -S -n -u root /bin/sh -c '”’“'”‘"’“'”‘"’“‘echo BECOME-SUCCESS-okpjvfdbdroxtqwhzdvrduetormgqnte; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1453751994.86-84090426534284/user; rm -rf “/home/vagrant/.ansible/tmp/ansible-tmp-1453751994.86-84090426534284/” > /dev/null 2>&1’”‘"’“'”‘"’“'”‘"’‘"’"‘’
changed: [127.0.0.1] => {“append”: false, “changed”: true, “comment”: “ircd”, “group”: 39, “home”: “/var/run/ircd”, “invocation”: {“module_args”: {“append”: false, “comment”: null, “createhome”: true, “expires”: null, “force”: false, “generate_ssh_key”: null, “group”: null, “groups”: null, “home”: null, “login_class”: null, “move_home”: false, “name”: “irc”, “non_unique”: false, “password”: null, “remove”: false, “shell”: null, “skeleton”: null, “ssh_key_bits”: “2048”, “ssh_key_comment”: “ansible-generated on vagrant”, “ssh_key_file”: null, “ssh_key_passphrase”: null, “ssh_key_type”: “rsa”, “state”: “present”, “system”: false, “uid”: null, “update_password”: “always”}, “module_name”: “user”}, “move_home”: false, “name”: “irc”, “shell”: “/usr/sbin/nologin”, “state”: “present”, “uid”: 39}

PLAY RECAP *********************************************************************
127.0.0.1 : ok=2 changed=1 unreachable=0 failed=0

vagrant@vagrant:~$ ansible-playbook --sudo -i hosts default.yml -vvvv
Using /etc/ansible/ansible.cfg as config file
Loaded callback default of type stdout, v2.0
1 plays in default.yml

PLAY ***************************************************************************

TASK [setup] *******************************************************************
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 ‘( umask 22 && mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1453751997.13-81608628853587 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1453751997.13-81608628853587 )” )’
<127.0.0.1> PUT /tmp/tmpSZ6nQL TO /home/vagrant/.ansible/tmp/ansible-tmp-1453751997.13-81608628853587/setup
<127.0.0.1> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r ‘[127.0.0.1]’
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 ‘/bin/sh -c ‘"’“'sudo -H -S -n -u root /bin/sh -c '”’“'”‘"’“'”‘"’“‘echo BECOME-SUCCESS-rfmughrvyutwbtodbhgxnzoxandscylx; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1453751997.13-81608628853587/setup; rm -rf “/home/vagrant/.ansible/tmp/ansible-tmp-1453751997.13-81608628853587/” > /dev/null 2>&1’”‘"’“'”‘"’“'”‘"’‘"’"‘’
ok: [127.0.0.1]

TASK [test] ********************************************************************
task path: /home/vagrant/default.yml:3
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 ‘( umask 22 && mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1453751997.42-28141592809195 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1453751997.42-28141592809195 )” )’
<127.0.0.1> PUT /tmp/tmpW0qBit TO /home/vagrant/.ansible/tmp/ansible-tmp-1453751997.42-28141592809195/user
<127.0.0.1> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r ‘[127.0.0.1]’
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 ‘/bin/sh -c ‘"’“'sudo -H -S -n -u root /bin/sh -c '”’“'”‘"’“'”‘"’“‘echo BECOME-SUCCESS-wrgqmozczlsgggiltsktnubjiwqdnzxm; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1453751997.42-28141592809195/user; rm -rf “/home/vagrant/.ansible/tmp/ansible-tmp-1453751997.42-28141592809195/” > /dev/null 2>&1’”‘"’“'”‘"’“'”‘"’‘"’"‘’
ok: [127.0.0.1] => {“append”: false, “changed”: false, “comment”: “ircd”, “group”: 39, “home”: “/var/run/ircd”, “invocation”: {“module_args”: {“append”: false, “comment”: null, “createhome”: true, “expires”: null, “force”: false, “generate_ssh_key”: null, “group”: null, “groups”: null, “home”: null, “login_class”: null, “move_home”: false, “name”: “irc”, “non_unique”: false, “password”: null, “remove”: false, “shell”: null, “skeleton”: null, “ssh_key_bits”: “2048”, “ssh_key_comment”: “ansible-generated on vagrant”, “ssh_key_file”: null, “ssh_key_passphrase”: null, “ssh_key_type”: “rsa”, “state”: “present”, “system”: false, “uid”: null, “update_password”: “always”}, “module_name”: “user”}, “move_home”: false, “name”: “irc”, “shell”: “/usr/sbin/nologin”, “state”: “present”, “uid”: 39}

PLAY RECAP *********************************************************************
127.0.0.1 : ok=2 changed=0 unreachable=0 failed=0

vagrant@vagrant:~$ sudo reboot
vagrant@vagrant:~$
Broadcast message from vagrant@vagrant
(/dev/pts/0) at 19:59 …

The system is going down for reboot NOW!
Connection to 127.0.0.1 closed by remote host.
Connection to 127.0.0.1 closed.
basti /tmp/test $ vagrant ssh
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-25-generic x86_64)

  • Documentation: https://help.ubuntu.com/
    Last login: Mon Jan 25 19:59:57 2016 from 127.0.0.1
    vagrant@vagrant:~$ ansible-playbook --sudo -i hosts default.yml -vvvv
    Using /etc/ansible/ansible.cfg as config file
    Loaded callback default of type stdout, v2.0
    1 plays in default.yml

PLAY ***************************************************************************

TASK [setup] *******************************************************************
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 ‘( umask 22 && mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1453752033.61-255131124518409 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1453752033.61-255131124518409 )” )’
<127.0.0.1> PUT /tmp/tmpWuVdyn TO /home/vagrant/.ansible/tmp/ansible-tmp-1453752033.61-255131124518409/setup
<127.0.0.1> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r ‘[127.0.0.1]’
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 ‘/bin/sh -c ‘"’“'sudo -H -S -n -u root /bin/sh -c '”’“'”‘"’“'”‘"’“‘echo BECOME-SUCCESS-ujfmzjtjprnybeysiwduqcnziorotoma; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1453752033.61-255131124518409/setup; rm -rf “/home/vagrant/.ansible/tmp/ansible-tmp-1453752033.61-255131124518409/” > /dev/null 2>&1’”‘"’“'”‘"’“'”‘"’‘"’"‘’
ok: [127.0.0.1]

TASK [test] ********************************************************************
task path: /home/vagrant/default.yml:3
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 ‘( umask 22 && mkdir -p “$( echo $HOME/.ansible/tmp/ansible-tmp-1453752034.25-251224463104142 )” && echo “$( echo $HOME/.ansible/tmp/ansible-tmp-1453752034.25-251224463104142 )” )’
<127.0.0.1> PUT /tmp/tmp_JWcYK TO /home/vagrant/.ansible/tmp/ansible-tmp-1453752034.25-251224463104142/user
<127.0.0.1> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r ‘[127.0.0.1]’
<127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: None
<127.0.0.1> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o Port=22 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r -tt 127.0.0.1 ‘/bin/sh -c ‘"’“'sudo -H -S -n -u root /bin/sh -c '”’“'”‘"’“'”‘"’“‘echo BECOME-SUCCESS-xdwzqkcbxmntnidstjypazillxojmsgv; LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1453752034.25-251224463104142/user; rm -rf “/home/vagrant/.ansible/tmp/ansible-tmp-1453752034.25-251224463104142/” > /dev/null 2>&1’”‘"’“'”‘"’“'”‘"’‘"’"‘’
changed: [127.0.0.1] => {“append”: false, “changed”: true, “comment”: “ircd”, “group”: 39, “home”: “/var/run/ircd”, “invocation”: {“module_args”: {“append”: false, “comment”: null, “createhome”: true, “expires”: null, “force”: false, “generate_ssh_key”: null, “group”: null, “groups”: null, “home”: null, “login_class”: null, “move_home”: false, “name”: “irc”, “non_unique”: false, “password”: null, “remove”: false, “shell”: null, “skeleton”: null, “ssh_key_bits”: “2048”, “ssh_key_comment”: “ansible-generated on vagrant”, “ssh_key_file”: null, “ssh_key_passphrase”: null, “ssh_key_type”: “rsa”, “state”: “present”, “system”: false, “uid”: null, “update_password”: “always”}, “module_name”: “user”}, “move_home”: false, “name”: “irc”, “shell”: “/usr/sbin/nologin”, “state”: “present”, “uid”: 39}

PLAY RECAP *********************************************************************
127.0.0.1 : ok=2 changed=1 unreachable=0 failed=0

`

`
root@vagrant:/home/vagrant# uname -a
Linux vagrant 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
root@vagrant:/home/vagrant# cat /etc/issue
Ubuntu 14.04.3 LTS \n \l

root@vagrant:/home/vagrant# ansible --version
ansible 2.0.0.2
config file = /etc/ansible/ansible.cfg
configured module search path = /usr/share/ansible

`

Why does this happen?

Regards
Sebastian