apt: AttributeError: module '__main__' has no attribute '_module_fqn'

See original GitHub issue
  • Which version of Ansible are you running?
ansible [core 2.11.2] 
  config file = ~/.ansible.cfg
  configured module search path = ['~/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/venv/lib/python3.9/site-packages/ansible
  ansible collection location = ~/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/venv/bin/ansible
  python version = 3.9.6 (default, Jul 16 2021, 00:00:00) [GCC 11.1.1 20210531 (Red Hat 11.1.1-3)]
  jinja version = 3.0.1
  libyaml = True
  • Is your version of Ansible patched in any way? no
  • Are you running with any custom modules, or module_utils loaded? no
  • Have you tried the latest master version from Git? yes
  • Mention your host and target OS and versions
    • host: Fedora 34
    • target: Debian 10 docker image
  • Mention your host and target Python versions
    • host: Python 3.9
    • target: Python 3.7

Example Playbook:

---
- name: Converge
  hosts: all

  tasks:
    - name: install vim
      ansible.builtin.apt:
        name: vim
        state: present

Error:

The full traceback is:
Traceback (most recent call last):
  File "master:/usr/local/share/mitogen/ansible_mitogen/runner.py", line 975, in _run
    self._run_code(code, mod)
  File "master:/usr/local/share/mitogen/ansible_mitogen/runner.py", line 939, in _run_code
    exec(code, vars(mod))
  File "master:/usr/local/venv/lib/python3.9/site-packages/ansible/modules/apt.py", line 1310, in <module>
  File "master:/usr/local/venv/lib/python3.9/site-packages/ansible/modules/apt.py", line 1114, in main
  File "master:/usr/local/venv/lib/python3.9/site-packages/ansible/module_utils/common/respawn.py", line 39, in respawn_module
    payload = _create_payload()
  File "master:/usr/local/venv/lib/python3.9/site-packages/ansible/module_utils/common/respawn.py", line 76, in _create_payload
    module_fqn = sys.modules['__main__']._module_fqn
AttributeError: module '__main__' has no attribute '_module_fqn'
fatal: [linux-debian-10]: FAILED! => {
    "ansible_facts": {},
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"master:/usr/local/share/mitogen/ansible_mitogen/runner.py\", line 975, in _run\n    self._run_code(code, mod)\n  File \"master:/usr/local/share/mitogen/ansible_mitogen/runner.py\", line 939, in _run_code\n    exec(code, vars(mod))\n  File \"master:/usr/local/venv/lib/python3.9/site-packages/ansible/modules/apt.py\", line 1310, in <module>\n  File \"master:/usr/local/venv/lib/python3.9/site-packages/ansible/modules/apt.py\", line 1114, in main\n  File \"master:/usr/local/venv/lib/python3.9/site-packages/ansible/module_utils/common/respawn.py\", line 39, in respawn_module\n    payload = _create_payload()\n  File \"master:/usr/local/venv/lib/python3.9/site-packages/ansible/module_utils/common/respawn.py\", line 76, in _create_payload\n    module_fqn = sys.modules['__main__']._module_fqn\nAttributeError: module '__main__' has no attribute '_module_fqn'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Verbose output: verbose.log.txt

Workarounds like:

  1. Adding vars: { mitogen_task_isolation: fork } to the task
  2. Adding ansible.builtin.apt to ALWAYS_FORK_MODULES in ansible_mitogen/planner.py

doesn’t work.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:7
  • Comments:21 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
baszoetekouwcommented, Jan 31, 2022

I think you are missing the point of this bug; sure, I’d be nice to have a workaround by setting the python interpreter to a different binary, but that still wouldn’t fix this bug.

The problem is that the ansible API has changed, and this breaks specific mitogen workflows. The solution should thus be to fix mitogen, not to avoid the specific circumstances in which this workflow is triggered.

2reactions
Links2004commented, Nov 23, 2021

can confirm the lastest master still has this problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

python3 for unit test: AttributeError: module '__main__' has no ...
if __name__ == "__main__": unittest.main(). It worked, but was failing before due to a mirror typo. I replaced: self.asertEqual. with: self.
Read more >
openssl - module 'lib' has no attribute ... - Ask Ubuntu
I ran into this with pyOpenSSL==19.0.0 and was able to fix this with pip3 install pyOpenSSL --upgrade.
Read more >
Traceback with ansible: AttributeError: 'module' object has no ...
This is fixed as hacking/env-setup or python setup.py egg_info was executed. AttributeError: 'module' object has no attribute '_vendor'. I'm getting ...
Read more >
AttributeError: 'module' object has no attribute 'main'
Hello all! I want to run turtlebot simulation. It has been complied correctly. But I run the main.launch file it gives me the...
Read more >
Frequently Asked Questions — schedule 1.1.0 documentation
AttributeError : 'module' object has no attribute 'every'. when I try to use schedule. This happens if your code imports the wrong schedule...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found