Phantom container running or broken Ansible?

I’ve got the below Ansible code:

---
- hosts: all
  become: yes
  become_method: sudo

  tasks:
    - name: Run a complex command within a "running" container
      community.general.lxc_container:
        name: mycontainer
        lxc_path: /snap/bin/
        container_log: true
        state: started
        container_command: |
          echo 'hello world.' | tee /home/${USER}/my_message
      register: clone_container_info
    - name: Debug info on container "mycontainer"
      ansible.builtin.debug:
        var: clone_container_info

When I run it, no matter if the container is deleted, Ansible comes back and says it was a success and that is is running.


TASK [Debug info on container "mycontainer"] ******************************

ok: [192.168.1.46] => {
    "clone_container_info": {
        "changed": true,
        "failed": false,
        "lxc_container": {
            "init_pid": 4848,
            "interfaces": [
                "eth0",
                "lo"
            ],
            "ips": [
                "10.0.3.49"
            ],
            "name": "mycontainer",
            "state": "running"
        }
    }
}

The ‘container_command’ never runs (even when the container did exist) and weirdly it still completes even though I deleted the container. My first thought was that it must be on the wrong server, but when I shutdown the server that it’s connecting to, it then throws an error that it can’t connect to 192.168.1.46.

So I have established that it is the correct server, but the container doesn’t exist:

If I change the yaml above to have a different container name, it then errors out and says the container doesn’t exist.

I’ve then decided to see if it’s somehow running on the Ansible machine, but it has no containers running. I thought maybe the Ansible machine was caching the result, but after a reboot it’s still doing the same thing.

Does anyone have any thought?

After some digging it appears to be a bug and Ansible is not handling it (for some reason it’s assuming a default of success). I won’t know until I can find a solution.