PyMutex error in lxc module when using lxc_container (Debian Trixie)

scherer
Fri, 15 Aug 2025 15:21:19 +0000
Get Help

Issue

When I execute and Ansible lxc_container task, I get no error in Ansible but the tasks fails on the remote end with “Fatal Python error: PyMutex_Unlock: unlocking mutex that is not locked“

Pre-requisites:

I’ve created a simple playbook to replicate the issue.

LXC host running

Debian 13 (13.0 Trixie)

Python (3.13.5)

LXC (1:6.0.4-4+b3)

python3-lxc (1:5.0.0-2+b3)

LXC container (also running Debian 13, but I’ve tried it with other versions such as bookworm and it has the same effect)

Playbook/Role:

- name: test container command
  lxc_container:
    name: ezra3
    state: started
    container_command: |
      echo -e “Hello World\n” >/root/hello_world.txt

I’ve ran the playbook with -vvvv and can see the error in the output. I’ve then preserved the tmp files and executed it again manually on the lxc host.

root@martha1:~/.ansible/tmp$ python3 ansible-tmp-1755260077.5821028-8449-254242578688725/AnsiballZ_lxc_container.py
Fatal Python error: PyMutex_Unlock: unlocking mutex that is not locked
Python runtime state: initialized

Current thread 0x00007fe8bb3f6100 (most recent call first):
  File "/tmp/ansible_lxc_container_payload_7dh2sfdk/ansible_lxc_container_payload.zip/ansible_collections/community/general/plugins/modules/lxc_container.py", line 934 in _execute_command
  File "/tmp/ansible_lxc_container_payload_7dh2sfdk/ansible_lxc_container_payload.zip/ansible_collections/community/general/plugins/modules/lxc_container.py", line 1156 in _started
  File "/tmp/ansible_lxc_container_payload_7dh2sfdk/ansible_lxc_container_payload.zip/ansible_collections/community/general/plugins/modules/lxc_container.py", line 1624 in run
  File "/tmp/ansible_lxc_container_payload_7dh2sfdk/ansible_lxc_container_payload.zip/ansible_collections/community/general/plugins/modules/lxc_container.py", line 1744 in main
  File "/tmp/ansible_lxc_container_payload_7dh2sfdk/ansible_lxc_container_payload.zip/ansible_collections/community/general/plugins/modules/lxc_container.py", line 1748 in <module>
  File "<frozen runpy>", line 88 in _run_code
  File "<frozen runpy>", line 98 in _run_module_code
  File "<frozen runpy>", line 226 in run_module
  File "/root/.ansible/tmp/ansible-tmp-1755260077.5821028-8449-254242578688725/AnsiballZ_lxc_container.py", line 122 in invoke_module
  File "/root/.ansible/tmp/ansible-tmp-1755260077.5821028-8449-254242578688725/AnsiballZ_lxc_container.py", line 249 in _ansiballz_main
  File "/root/.ansible/tmp/ansible-tmp-1755260077.5821028-8449-254242578688725/AnsiballZ_lxc_container.py", line 259 in <module>

Extension modules: _lxc (total: 1)

{"changed": true, "lxc_container": {"interfaces": ["eth0", "lo"], "ips": ["192.168.1.180", "fd40:5d5f:73d0:5a9a:1266:6aff:fee9:9a17"], "state": "running", "init_pid": 71820, "name": "ezra3"}, "invocation": {"module_args": {"name": "ezra3", "state": "started", "container_command": "echo -e \"Hello World\\n\" >/root/hello_world.txt\n", "template": "ubuntu", "backing_store": "dir", "vg_name": "lxc", "fs_type": "ext4", "fs_size": "5G", "container_log": false, "container_log_level": "INFO", "clone_snapshot": false, "archive": false, "archive_compression": "gzip", "template_options": null, "config": null, "thinpool": null, "directory": null, "zfs_root": null, "lv_name": "ezra3", "lxc_path": null, "container_config": null, "clone_name": null, "archive_path": null}}}

The exact same playbook works fine on an older Debian 12 (bookworm) host.

2 posts - 2 participants