MODULE FAILURE: No start of json char found

Upgrading from ansible-core-2.12 to ansible-11.8.0 (ansible-core-2.18.7) and basic tasks are failing. The issues seem to happen only in molecule testing.

I am working in a vscode devcontainer on macOS 15 and Docker Desktop

sw_vers 
ProductName:		macOS
ProductVersion:		15.6
BuildVersion:		24G84

docker --version
Docker version 28.3.3-1, build 980b85681696fbd95927fd8ded8f6d91bdca95b0

docker desktop
4.44.0 (201307)

python -V
Python 3.13.6

ansible --version
ansible [core 2.18.7]
  config file = None
  configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vscode/.venv/lib/python3.13/site-packages/ansible
  ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/vscode/.venv/bin/ansible
  python version = 3.13.6 (main, Aug  8 2025, 17:10:04) [Clang 20.1.4 ] (/home/vscode/.venv/bin/python)
  jinja version = 3.1.6
  libyaml = True


molecule --version
[DEPRECATION WARNING]: [defaults]collections_paths option. Reason: does not fit
 var naming standard, use the singular form collections_path instead 
Alternatives: none. This feature will be removed in version 2.19. Deprecation 
warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
 [DEPRECATED] [defaults]collections_paths option. Reason: does not fit var naming standard, use the singular form collections_path instead
Alternatives: none, to be removed in 2.19
molecule 25.7.0 using python 3.13 
    ansible:2.18.7
    docker:23.7.0 from molecule_plugins requiring collections: community.docker>=3.10.2 ansible.posix>=1.4.0
    gce:23.7.0 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
    podman:23.7.0 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
    ec2:23.7.0 from molecule_plugins
    openstack:23.7.0 from molecule_plugins requiring collections: openstack.cloud>=2.1.0
    azure:23.7.0 from molecule_plugins
    vagrant:23.7.0 from molecule_plugins
    containers:23.7.0 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
    default:25.7.0 from molecule

uv pip list | grep molecule-
molecule-plugins               23.7.0

My molecule converge.yml:

---
- name: Converge
  hosts: all
  gather_facts: true
  become: true

   pre_tasks:
    - name: Package update (apt)
      ansible.builtin.apt:
        update_cache: true
      changed_when: false
      when: ansible_os_family == 'Debian'``

Non-debug and non-verbose:

$ molecule converge 
WARNING  Driver docker does not provide a schema.
WARNING  Driver docker does not provide a schema.
INFO     default ➜ discovery: scenario test matrix: dependency, create, prepare, converge
INFO     default ➜ prerun: Performing prerun with role_name_check=0...
INFO     default ➜ dependency: Starting
WARNING  default ➜ dependency: Skipping, missing the requirements file.
WARNING  default ➜ dependency: Skipping, missing the requirements file.
INFO     default ➜ dependency: Completed
INFO     default ➜ create: Starting
WARNING  default ➜ create: Skipping, instances already created.
INFO     default ➜ create: Completed
INFO     default ➜ prepare: Starting
WARNING  default ➜ prepare: Skipping, prepare playbook not configured.
INFO     default ➜ prepare: Completed
INFO     default ➜ converge: Starting
INFO     default ➜ converge: ansible-playbook version: ansible-playbook 
  config file = None
  configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vscode/.venv/lib/python3.13/site-packages/ansible
  ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/vscode/.venv/bin/ansible-playbook
  python version = 3.13.6 (main, Aug  8 2025, 17:10:04)  (/home/vscode/.venv/bin/python)
  jinja version = 3.1.6
  libyaml = True
INFO     Sanity checks: 'docker'

PLAY [Converge] ****************************************************************

TASK [Gathering Facts] *********************************************************
ok: [jammy]

TASK [Package update (apt)] ****************************************************
fatal: [jammy]: FAILED! => {"changed": false, "module_stderr": "", "module_stdout": "", "msg": "MODULE FAILURE: No start of json char found\nSee stdout/stderr for the exact error", "rc": 0}

PLAY RECAP *********************************************************************
jammy                      : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

CRITICAL Ansible return code was 2, command was: ansible-playbook --inventory /home/vscode/.ansible/tmp/molecule.ZdnW.default/inventory --skip-tags molecule-notest,notest /workspace/collections/ansible_collections/realtime/logging/roles/alloy/molecule/default/converge.yml[/dim]

Debug and verbose

$ MOLECULE_LOG_LEVEL=DEBUG MOLECULE_DEBUG=1 molecule converge -- -vvv
DEBUG    default ➜ validate: Validating schema /workspace/collections/ansible_collections/realtime/logging/roles/alloy/molecule/default/molecule.yml.
WARNING  Driver docker does not provide a schema.
DEBUG    default ➜ validate: Validating schema /workspace/collections/ansible_collections/realtime/logging/roles/alloy/molecule/default/molecule.yml.
WARNING  Driver docker does not provide a schema.
INFO     default ➜ discovery: scenario test matrix: dependency, create, prepare, converge
INFO     default ➜ prerun: Performing prerun with role_name_check=0...
INFO     default ➜ dependency: Starting
WARNING  default ➜ dependency: Skipping, missing the requirements file.
WARNING  default ➜ dependency: Skipping, missing the requirements file.
INFO     default ➜ dependency: Completed
INFO     default ➜ create: Starting
WARNING  default ➜ create: Skipping, instances already created.
INFO     default ➜ create: Completed
INFO     default ➜ prepare: Starting
WARNING  default ➜ prepare: Skipping, prepare playbook not configured.
INFO     default ➜ prepare: Completed
INFO     default ➜ converge: Starting
INFO     default ➜ converge: ansible-playbook version: ansible-playbook 
  config file = None
  configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vscode/.venv/lib/python3.13/site-packages/ansible
  ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/vscode/.venv/bin/ansible-playbook
  python version = 3.13.6 (main, Aug  8 2025, 17:10:04)  (/home/vscode/.venv/bin/python)
  jinja version = 3.1.6
  libyaml = True
INFO     Sanity checks: 'docker'
DEBUG: ANSIBLE ENVIRONMENT:
ANSIBLE_CONFIG: /home/vscode/.ansible/tmp/molecule.ZdnW.default/ansible.cfg
ANSIBLE_FORCE_COLOR: '1'

DEBUG: MOLECULE ENVIRONMENT:
MOLECULE_DEBUG: 'True'
MOLECULE_DEPENDENCY_NAME: galaxy
MOLECULE_DRIVER_NAME: docker
MOLECULE_ENV_FILE: /workspace/collections/ansible_collections/realtime/logging/roles/alloy/.env.yml
MOLECULE_EPHEMERAL_DIRECTORY: /home/vscode/.ansible/tmp/molecule.ZdnW.default
MOLECULE_FILE: /home/vscode/.ansible/tmp/molecule.ZdnW.default/molecule.yml
MOLECULE_INSTANCE_CONFIG: /home/vscode/.ansible/tmp/molecule.ZdnW.default/instance_config.yml
MOLECULE_INVENTORY_FILE: /home/vscode/.ansible/tmp/molecule.ZdnW.default/inventory/ansible_inventory.yml
MOLECULE_LOG_LEVEL: DEBUG
MOLECULE_PROJECT_DIRECTORY: /workspace/collections/ansible_collections/realtime/logging/roles/alloy
MOLECULE_PROVISIONER_NAME: ansible
MOLECULE_SCENARIO_DIRECTORY: /workspace/collections/ansible_collections/realtime/logging/roles/alloy/molecule/default
MOLECULE_SCENARIO_NAME: default
MOLECULE_STATE_FILE: /home/vscode/.ansible/tmp/molecule.ZdnW.default/state.yml
MOLECULE_VERIFIER_NAME: ansible
MOLECULE_VERIFIER_TEST_DIRECTORY: /workspace/collections/ansible_collections/realtime/logging/roles/alloy/molecule/default/tests

DEBUG: SHELL REPLAY:
ANSIBLE_CONFIG=/home/vscode/.ansible/tmp/molecule.ZdnW.default/ansible.cfg ANSIBLE_FORCE_COLOR=1 MOLECULE_DEBUG=True MOLECULE_DEPENDENCY_NAME=galaxy MOLECULE_DRIVER_NAME=docker MOLECULE_ENV_FILE=/workspace/collections/ansible_collections/realtime/logging/roles/alloy/.env.yml MOLECULE_EPHEMERAL_DIRECTORY=/home/vscode/.ansible/tmp/molecule.ZdnW.default MOLECULE_FILE=/home/vscode/.ansible/tmp/molecule.ZdnW.default/molecule.yml MOLECULE_INSTANCE_CONFIG=/home/vscode/.ansible/tmp/molecule.ZdnW.default/instance_config.yml MOLECULE_INVENTORY_FILE=/home/vscode/.ansible/tmp/molecule.ZdnW.default/inventory/ansible_inventory.yml MOLECULE_LOG_LEVEL=DEBUG MOLECULE_PROJECT_DIRECTORY=/workspace/collections/ansible_collections/realtime/logging/roles/alloy MOLECULE_PROVISIONER_NAME=ansible MOLECULE_SCENARIO_DIRECTORY=/workspace/collections/ansible_collections/realtime/logging/roles/alloy/molecule/default MOLECULE_SCENARIO_NAME=default MOLECULE_STATE_FILE=/home/vscode/.ansible/tmp/molecule.ZdnW.default/state.yml MOLECULE_VERIFIER_NAME=ansible MOLECULE_VERIFIER_TEST_DIRECTORY=/workspace/collections/ansible_collections/realtime/logging/roles/alloy/molecule/default/tests
ansible-playbook [core 2.18.7]
  config file = /home/vscode/.ansible/tmp/molecule.ZdnW.default/ansible.cfg
  configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vscode/.venv/lib/python3.13/site-packages/ansible
  ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/vscode/.venv/bin/ansible-playbook
  python version = 3.13.6 (main, Aug  8 2025, 17:10:04) [Clang 20.1.4 ] (/home/vscode/.venv/bin/python)
  jinja version = 3.1.6
  libyaml = True
Using /home/vscode/.ansible/tmp/molecule.ZdnW.default/ansible.cfg as config file
host_list declined parsing /home/vscode/.ansible/tmp/molecule.ZdnW.default/inventory/ansible_inventory.yml as it did not pass its verify_file() method
script declined parsing /home/vscode/.ansible/tmp/molecule.ZdnW.default/inventory/ansible_inventory.yml as it did not pass its verify_file() method
Parsed /home/vscode/.ansible/tmp/molecule.ZdnW.default/inventory/ansible_inventory.yml inventory source with yaml plugin
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
1 plays in /workspace/collections/ansible_collections/realtime/logging/roles/alloy/molecule/default/converge.yml

PLAYBOOK: converge.yml *********************************************************

PLAY [Converge] ****************************************************************

TASK [Gathering Facts] *********************************************************
task path: /workspace/collections/ansible_collections/realtime/logging/roles/alloy/molecule/default/converge.yml:2
<jammy> ESTABLISH DOCKER CONNECTION FOR USER: root
<jammy> EXEC ['/usr/bin/docker', b'exec', b'-i', 'jammy', '/bin/sh', '-c', '/bin/sh -c \'( umask 77 && mkdir -p "` echo /tmp/.ansible/tmp `"&& mkdir "` echo /tmp/.ansible/tmp/ansible-tmp-1754933818.4667227-8682-116366923936695 `" && echo ansible-tmp-1754933818.4667227-8682-116366923936695="` echo /tmp/.ansible/tmp/ansible-tmp-1754933818.4667227-8682-116366923936695 `" ) && sleep 0\'']
<jammy> Attempting python interpreter discovery
<jammy> EXEC ['/usr/bin/docker', b'exec', b'-i', 'jammy', '/bin/sh', '-c', '/bin/sh -c \'echo PLATFORM; uname; echo FOUND; command -v \'"\'"\'python3.13\'"\'"\'; command -v \'"\'"\'python3.12\'"\'"\'; command -v \'"\'"\'python3.11\'"\'"\'; command -v \'"\'"\'python3.10\'"\'"\'; command -v \'"\'"\'python3.9\'"\'"\'; command -v \'"\'"\'python3.8\'"\'"\'; command -v \'"\'"\'/usr/bin/python3\'"\'"\'; command -v \'"\'"\'python3\'"\'"\'; echo ENDFOUND && sleep 0\'']
<jammy> EXEC ['/usr/bin/docker', b'exec', b'-i', 'jammy', '/bin/sh', '-c', "/bin/sh -c '/usr/bin/python3.10 && sleep 0'"]
<jammy> Python interpreter discovery fallback (unsupported Linux distribution: ubuntu)
Using module file /home/vscode/.venv/lib/python3.13/site-packages/ansible/modules/setup.py
<jammy> PUT /home/vscode/.ansible/tmp/ansible-local-8664b5y3y493/tmptz86g5en TO /tmp/.ansible/tmp/ansible-tmp-1754933818.4667227-8682-116366923936695/AnsiballZ_setup.py
<jammy> EXEC ['/usr/bin/docker', b'exec', b'-i', 'jammy', '/bin/sh', '-c', "/bin/sh -c 'chmod u+rwx /tmp/.ansible/tmp/ansible-tmp-1754933818.4667227-8682-116366923936695/ /tmp/.ansible/tmp/ansible-tmp-1754933818.4667227-8682-116366923936695/AnsiballZ_setup.py && sleep 0'"]
<jammy> EXEC ['/usr/bin/docker', b'exec', b'-i', 'jammy', '/bin/sh', '-c', '/bin/sh -c \'sudo -H -S -n  -u root /bin/sh -c \'"\'"\'echo BECOME-SUCCESS-sgxabdpfbzvvrdmmvprdiovxdgpnrxsc ; /usr/bin/python3.10 /tmp/.ansible/tmp/ansible-tmp-1754933818.4667227-8682-116366923936695/AnsiballZ_setup.py\'"\'"\' && sleep 0\'']
<jammy> EXEC ['/usr/bin/docker', b'exec', b'-i', 'jammy', '/bin/sh', '-c', "/bin/sh -c 'rm -f -r /tmp/.ansible/tmp/ansible-tmp-1754933818.4667227-8682-116366923936695/ > /dev/null 2>&1 && sleep 0'"]
ok: [jammy]

TASK [Package update (apt)] ****************************************************
task path: /workspace/collections/ansible_collections/realtime/logging/roles/alloy/molecule/default/converge.yml:10
<jammy> ESTABLISH DOCKER CONNECTION FOR USER: root
<jammy> EXEC ['/usr/bin/docker', b'exec', b'-i', 'jammy', '/bin/sh', '-c', '/bin/sh -c \'( umask 77 && mkdir -p "` echo /tmp/.ansible/tmp `"&& mkdir "` echo /tmp/.ansible/tmp/ansible-tmp-1754933819.4123073-8800-78678785547890 `" && echo ansible-tmp-1754933819.4123073-8800-78678785547890="` echo /tmp/.ansible/tmp/ansible-tmp-1754933819.4123073-8800-78678785547890 `" ) && sleep 0\'']
Using module file /home/vscode/.venv/lib/python3.13/site-packages/ansible/modules/apt.py
<jammy> PUT /home/vscode/.ansible/tmp/ansible-local-8664b5y3y493/tmpx1zu_qvj TO /tmp/.ansible/tmp/ansible-tmp-1754933819.4123073-8800-78678785547890/AnsiballZ_apt.py
<jammy> EXEC ['/usr/bin/docker', b'exec', b'-i', 'jammy', '/bin/sh', '-c', "/bin/sh -c 'chmod u+rwx /tmp/.ansible/tmp/ansible-tmp-1754933819.4123073-8800-78678785547890/ /tmp/.ansible/tmp/ansible-tmp-1754933819.4123073-8800-78678785547890/AnsiballZ_apt.py && sleep 0'"]
<jammy> EXEC ['/usr/bin/docker', b'exec', b'-i', 'jammy', '/bin/sh', '-c', '/bin/sh -c \'sudo -H -S -n  -u root /bin/sh -c \'"\'"\'echo BECOME-SUCCESS-stqmenxchjgirbmsuaaohbfkmdkeiodt ; /usr/bin/python3.10 /tmp/.ansible/tmp/ansible-tmp-1754933819.4123073-8800-78678785547890/AnsiballZ_apt.py\'"\'"\' && sleep 0\'']
<jammy> EXEC ['/usr/bin/docker', b'exec', b'-i', 'jammy', '/bin/sh', '-c', "/bin/sh -c 'rm -f -r /tmp/.ansible/tmp/ansible-tmp-1754933819.4123073-8800-78678785547890/ > /dev/null 2>&1 && sleep 0'"]
fatal: [jammy]: FAILED! => {
    "changed": false,
    "module_stderr": "",
    "module_stdout": "",
    "msg": "MODULE FAILURE: No start of json char found\nSee stdout/stderr for the exact error",
    "rc": 0
}

PLAY RECAP *********************************************************************
jammy                      : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

CRITICAL Ansible return code was 2, command was: ansible-playbook --diff --inventory /home/vscode/.ansible/tmp/molecule.ZdnW.default/inventory --skip-tags molecule-notest,notest -vvv /workspace/collections/ansible_collections/realtime/logging/roles/alloy/molecule/default/converge.yml[/dim]

I followed many of the posts I could find regarding “No start of json char found” and spent a lot of time with GPT-5 without any success. The posts and GPT keep stating this issue is a container problem. I do not agree.

Interactive shell and CLI works as expected. Ansible raw works:

---
- name: Converge
  hosts: all
  gather_facts: true
  become: true

  pre_tasks:
    - name: Update
      raw: |
        DEBIAN_FRONTEND=noninteractive apt-get update
$ molecule converge 
WARNING  Driver docker does not provide a schema.
WARNING  Driver docker does not provide a schema.
INFO     default ➜ discovery: scenario test matrix: dependency, create, prepare, converge
INFO     default ➜ prerun: Performing prerun with role_name_check=0...
INFO     default ➜ dependency: Starting
WARNING  default ➜ dependency: Skipping, missing the requirements file.
WARNING  default ➜ dependency: Skipping, missing the requirements file.
INFO     default ➜ dependency: Completed
INFO     default ➜ create: Starting
WARNING  default ➜ create: Skipping, instances already created.
INFO     default ➜ create: Completed
INFO     default ➜ prepare: Starting
WARNING  default ➜ prepare: Skipping, prepare playbook not configured.
INFO     default ➜ prepare: Completed
INFO     default ➜ converge: Starting
INFO     default ➜ converge: ansible-playbook version: ansible-playbook 
  config file = None
  configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vscode/.venv/lib/python3.13/site-packages/ansible
  ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/vscode/.venv/bin/ansible-playbook
  python version = 3.13.6 (main, Aug  8 2025, 17:10:04)  (/home/vscode/.venv/bin/python)
  jinja version = 3.1.6
  libyaml = True
INFO     Sanity checks: 'docker'

PLAY [Converge] ****************************************************************

TASK [Gathering Facts] *********************************************************
ok: [jammy]

TASK [Update] ******************************************************************
changed: [jammy]

PLAY RECAP *********************************************************************
jammy                      : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

INFO     default ➜ converge: Completed
(ansible-playbooks) vscode ➜ .../realtime/logging/roles/alloy (main) $ molecule converge 
WARNING  Driver docker does not provide a schema.
WARNING  Driver docker does not provide a schema.
INFO     default ➜ discovery: scenario test matrix: dependency, create, prepare, converge
INFO     default ➜ prerun: Performing prerun with role_name_check=0...
INFO     default ➜ dependency: Starting
WARNING  default ➜ dependency: Skipping, missing the requirements file.
WARNING  default ➜ dependency: Skipping, missing the requirements file.
INFO     default ➜ dependency: Completed
INFO     default ➜ create: Starting
WARNING  default ➜ create: Skipping, instances already created.
INFO     default ➜ create: Completed
INFO     default ➜ prepare: Starting
WARNING  default ➜ prepare: Skipping, prepare playbook not configured.
INFO     default ➜ prepare: Completed
INFO     default ➜ converge: Starting
INFO     default ➜ converge: ansible-playbook version: ansible-playbook 
  config file = None
  configured module search path = ['/home/vscode/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vscode/.venv/lib/python3.13/site-packages/ansible
  ansible collection location = /home/vscode/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/vscode/.venv/bin/ansible-playbook
  python version = 3.13.6 (main, Aug  8 2025, 17:10:04)  (/home/vscode/.venv/bin/python)
  jinja version = 3.1.6
  libyaml = True
INFO     Sanity checks: 'docker'

PLAY [Converge] ****************************************************************

TASK [Gathering Facts] *********************************************************
ok: [jammy]

TASK [Update] ******************************************************************
changed: [jammy]

PLAY RECAP *********************************************************************
jammy                      : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

INFO     default ➜ converge: Completed

Any help would be appreciated.

I think this is a molecule problem, but I am starting here.

I continued troubleshooting. Testing playbook.

---
- name: Testing
  hosts: all
  connection: docker
  gather_facts: false

  tasks:
    - name: Check curl installed with apt module
      ansible.builtin.apt:
        name: curl
        state: present
$ export ANSIBLE_KEEP_REMOTE_FILES=1
$ ansible-playbook -i jammy, -c docker -e ansible_python_interpreter=/usr/bin/python3 playbooks/test-docker-connection.yml -vvvv -u root
<snip>
fatal: [jammy]: FAILED! => {
    "changed": false,
    "module_stderr": "",
    "module_stdout": "",
    "msg": "MODULE FAILURE: No start of json char found\nSee stdout/stderr for the exact error",
    "rc": 0
}

Consoled into the jammy docker container

# cd /root/.ansible/tmp/ansible-tmp-1754937943.4795835-12970-16199230815528
python3 AnsiballZ_apt.py 
                            <== THIS BLANK LINE
{"changed": false, "cache_updated": false, "cache_update_time": 1754936712, "invocation": {"module_args": {"name": "curl", "state": "present", "package": ["curl"], "update_cache_retries": 5, "update_cache_retry_max_delay": 12, "cache_valid_time": 0, "purge": false, "force": false, "upgrade": null, "dpkg_options": "force-confdef,force-confold", "autoremove": false, "autoclean": false, "fail_on_autoremove": false, "only_upgrade": false, "force_apt_get": false, "clean": false, "allow_unauthenticated": false, "allow_downgrade": false, "allow_change_held_packages": false, "lock_timeout": 60, "update_cache": null, "deb": null, "default_release": null, "install_recommends": null, "policy_rc_d": null}}}

I think the problem is that blank line?

python3 -u AnsiballZ_apt.py | hexdump -C
00000000  0a 7b 22 63 68 61 6e 67  65 64 22 3a 20 66 61 6c  |.{"changed": fal|
00000010  73 65 2c 20 22 63 61 63  68 65 5f 75 70 64 61 74  |se, "cache_updat|

<snip>

leading 0a byte at the very start is a newline character

More troubleshooting. Controlling tty issue in the docker connector? Keep the remote files so I can troubleshoot with them

$ export ANSIBLE_KEEP_REMOTE_FILES=1
$ docker exec jammy /usr/bin/python3.10 /tmp/.ansible/tmp/ansible-tmp-1754952848.1407292-87096-56280954989641/AnsiballZ_apt.py
$ echo $?
0

Give docker

-i is for interactive (keep STDIN open)

-t allocates a pseudo-TTY, which can change how buffering and output behave

$ docker exec -it jammy /usr/bin/python3.10 /tmp/.ansible/tmp/ansible-tmp-1754952848.1407292-87096-56280954989641/AnsiballZ_apt.py

{"changed": false, "cache_updated": false, "cache_update_time": 1754953554, "invocation": {"module_args": {"update_cache": true, "state": "present", "update_cache_retries": 5, "update_cache_retry_max_delay": 12, "cache_valid_time": 0, "purge": false, "force": false, "upgrade": null, "dpkg_options": "force-confdef,force-confold", "autoremove": false, "autoclean": false, "fail_on_autoremove": false, "only_upgrade": false, "force_apt_get": false, "clean": false, "allow_unauthenticated": false, "allow_downgrade": false, "allow_change_held_packages": false, "lock_timeout": 60, "package": null, "deb": null, "default_release": null, "install_recommends": null, "policy_rc_d": null}}}

ansible/plugins/action/_init_.py:1533

        rc, stdout, stderr = self._connection.exec_command(
            cmd, in_data=in_data, sudoable=sudoable
        )
        print(f"rc={rc}::stdout={stdout}::stderr={stderr}::cmd={cmd}")

There is no output on stdout and stderr? See the docker interactive flag but not the tty flag.

<jammy> EXEC ['/usr/bin/docker', b'exec', b'-i', 'jammy', '/bin/sh', '-c', "/bin/sh -c '/usr/bin/python3.10 /tmp/.ansible/tmp/ansible-tmp-1754954072.5935555-91591-205244058283265/AnsiballZ_apt.py && sleep 0'"] 

rc=0::stdout=b''::stderr=b''::cmd=/bin/sh -c '/usr/bin/python3.10 /tmp/.ansible/tmp/ansible-tmp-1754954072.5935555-91591-205244058283265/AnsiballZ_apt.py && sleep 0' [], 'stderr': '', 'stderr_lines': 

[]} fatal: [jammy]: FAILED! => {     "changed": false,     "module_stderr": "",     "module_stdout": "",     "msg": "MODULE FAILURE: 1 No start of json char found\nSee stdout/stderr for the exact error",     "rc": 0 }

Only the interactive flag does output to stdout

$ docker exec -i jammy /usr/bin/python3.10 /tmp/.ansible/tmp/ansible-tmp-1754952848.1407292-87096-56280954989641/AnsiballZ_apt.py

{"changed": false, "cache_updated": false, "cache_update_time": 1754953554, "invocation": {"module_args": {"update_cache": true, "state": "present", "update_cache_retries": 5, "update_cache_retry_max_delay": 12, "cache_valid_time": 0, "purge": false, "force": false, "upgrade": null, "dpkg_options": "force-confdef,force-confold", "autoremove": false, "autoclean": false, "fail_on_autoremove": false, "only_upgrade": false, "force_apt_get": false, "clean": false, "allow_unauthenticated": false, "allow_downgrade": false, "allow_change_held_packages": false, "lock_timeout": 60, "package": null, "deb": null, "default_release": null, "install_recommends": null, "policy_rc_d": null}}}