module 'platform' has no attribute 'dist' on Ubuntu 20.04

798 views
Skip to first unread message

Jeff Dickens

unread,
Aug 19, 2020, 11:39:51 AM8/19/20
to Ansible Project
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

Dick Visser

unread,
Aug 19, 2020, 4:07:25 PM8/19/20
to ansible...@googlegroups.com
Try removing "gather_facts: no" (i.e. do gather facts)
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8fa14750-20b7-4c03-864c-4f31116e4b02n%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Abhijeet Kasurde

unread,
Aug 20, 2020, 12:39:09 AM8/20/20
to ansible...@googlegroups.com
Jeff, what is Python version?



--
Thanks,
Abhijeet Kasurde
Reply all
Reply to author
Forward
0 new messages