Repository: ansible/ansible

Issue:
become_user: admin broken
##### SUMMARY
become_user: admin is broken in ansible-2.5.4 (and somewhere after version 2.4.3)
(but any other user is fine)

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
become_user

##### ANSIBLE VERSION
```
ansible 2.5.4
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]
```
(from the ansible ppa)

##### CONFIGURATION
("ansible-config dump --only-changed" is empty)

##### OS / ENVIRONMENT
Xenial LXD container from https://cloud-images.ubuntu.com/releases

##### STEPS TO REPRODUCE
This one DOES NOT work in 2.5.4-1ppa\~xenial, but does work for 2.4.3.0-1ppa\~xenial
(the first to steps are to assert a clean slate)
```yaml
---
- hosts: all
  vars:
    ansible_connection: local
  tasks:
  - file:
      path: /tmp/bla
      state: absent

  - user:
      name: admin
      state: absent

  - name: Set up local user account
    user:
      name: admin

  - copy:
      content: a
      dest: /tmp/bla
    become_user: admin
    become: True
```

However, replacing 'admin' with 'admin2' works fine:
```yaml
---
- hosts: all
  vars:
    ansible_connection: local
  tasks:
  - file:
      path: /tmp/bla
      state: absent

  - user:
      name: admin2
      state: absent

  - name: Set up local user account
    user:
      name: admin2

  - copy:
      content: a
      dest: /tmp/bla
    become_user: admin2
    become: True
```

##### EXPECTED RESULTS
```
TASK [copy] *********************************************************************************************************************************************
changed: [localhost]
```
(it seems like since ansible 2.4.3 extra semantics got introduced that caused a regression if I use the user 'admin' with become_user/sudo)

##### ACTUAL RESULTS
RESULT:
```
fatal: [localhost]: FAILED! => {"msg": "Failed to get information on remote file (/tmp/bla): sudo: unable to resolve host xenial\n/usr/bin/python: can't open file '/root/.ansible/tmp/ansible-tmp-1528233421.37-38091239630384/stat.py': [Errno 13] Permission denied\n"}
```

Verbose:
```
TASK [copy] *********************************************************************************************************************************************
task path: /tmp/bork.yml:18
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1528233655.1-12799021408589 `" && echo ansible-tmp-1528233655.1-12799021408589="` echo /root/.ansible/tmp/ansible-tmp-1528233655.1-12799021408589 `" ) && sleep 0'
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/files/stat.py
<localhost> PUT /root/.ansible/tmp/ansible-local-14813pphcn6/tmpaVlJms TO /root/.ansible/tmp/ansible-tmp-1528233655.1-12799021408589/stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1528233655.1-12799021408589/ /root/.ansible/tmp/ansible-tmp-1528233655.1-12799021408589/stat.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -n -u admin /bin/sh -c '"'"'echo BECOME-SUCCESS-tcfzbkkhwkntqcsventiagdvdumgnuhl; /usr/bin/python /root/.ansible/tmp/ansible-tmp-1528233655.1-12799021408589/stat.py'"'"' && sleep 0'
fatal: [localhost]: FAILED! => {
    "msg": "Failed to get information on remote file (/tmp/bla): sudo: unable to resolve host xenial\n/usr/bin/python: can't open file '/root/.ansible/tmp/ansible-tmp-1528233655.1-12799021408589/stat.py': [Errno 13] Permission denied\n"
}
```



Discussion:
Files identified in the description:
None

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->

Resolving patch:
diff --git a/lib/ansible/utils/module_docs_fragments/shell_common.py b/lib/ansible/utils/module_docs_fragments/shell_common.py
--- a/lib/ansible/utils/module_docs_fragments/shell_common.py
+++ b/lib/ansible/utils/module_docs_fragments/shell_common.py
@@ -47,9 +47,10 @@ class ModuleDocFragment(object):
       - dictionary of environment variables and their values to use when executing commands.
   admin_users:
     type: list
-    default: ['root', 'toor', 'admin']
+    default: ['root', 'toor']
     description:
-      - list of users to be expected to have admin privileges, for BSD you might want to add 'toor' for windows 'Administrator'.
+      - list of users to be expected to have admin privileges. This is used by the controller to
+        determine how to share temporary files between the remote user and the become user.
     env:
       - name: ANSIBLE_ADMIN_USERS
     ini:


Test patch: