When I try to use the user module with a Ubuntu 20 host, I get a failure as follows:
jeff@ansible:~$ ansible-playbook -l owl j_ansible_user.yaml
PLAY [create ansible user] *****************************************************
TASK [user] ********************************************************************
fatal: [owl]: FAILED! => {"changed": false, "module_stderr": "Shared connection to owl closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_bonof17k/ansible_modlib.zip/ansible/module_utils/basic.py\", line 274, in get_distribution\r\nAttributeError: module 'platform' has no attribute '_supported_dists'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"/tmp/ansible_bonof17k/ansible_module_user.py\", line 2300, in <module>\r\n main()\r\n File \"/tmp/ansible_bonof17k/ansible_module_user.py\", line 2205, in main\r\n user = User(module)\r\n File \"/tmp/ansible_bonof17k/ansible_module_user.py\", line 264, in __new__\r\n return load_platform_subclass(User, args, kwargs)\r\n File \"/tmp/ansible_bonof17k/ansible_modlib.zip/ansible/module_utils/basic.py\", line 332, in load_platform_subclass\r\n File \"/tmp/ansible_bonof17k/ansible_modlib.zip/ansible/module_utils/basic.py\", line 284, in get_distribution\r\nAttributeError: module 'platform' has no attribute 'dist'\r\n", "msg": "MODULE FAILURE", "rc": 1}
to retry, use: --limit @/home/jeff/j_ansible_user.retry
PLAY RECAP *********************************************************************
owl : ok=0 changed=0 unreachable=0 failed=1
jeff@ansible:~$ ansible owl -b -a whoami
owl | SUCCESS | rc=0 >>
root
jeff@ansible:~$ ansible owl -m ping
owl | SUCCESS => {
"changed": false,
"ping": "pong"
}
The playbook is this:
---
- name: create ansible user
hosts: linux-servers
gather_facts: no
become: true
tasks:
- user:
name: ansible
comment: ansible user
state: present
groups: adm,sudo
shell: /bin/bash
Other modules, or ad-hoc commands work fine.
jeff@ansible:~$ more jeff_sudoers.yaml
---
- name: copy sudoers/jeff
hosts: linux-servers
gather_facts: no
become: true
tasks:
- name: copy file sudoers/jeff
copy:
src: /home/jeff/sudoers/jeff
dest: /etc/sudoers.d/jeff
owner: root
group: root
mode: '0600'
jeff@ansible:~$ ansible-playbook -l owl jeff_sudoers.yaml
PLAY [copy sudoers/jeff] **********************************************************************************************************
TASK [copy file sudoers/jeff] *****************************************************************************************************
ok: [owl]
PLAY RECAP ************************************************************************************************************************
owl : ok=1 changed=0 unreachable=0 failed=0
jeff@ansible:~$
jeff@ansible:~$ ansible owl -m ping
owl | SUCCESS => {
"changed": false,
"ping": "pong"
}
jeff@ansible:~$ ansible owl -a date
owl | SUCCESS | rc=0 >>
Wed 19 Aug 2020 03:38:12 PM UTC
jeff@ansible:~$ ansible owl -b -a whoami
owl | SUCCESS | rc=0 >>
root