Ansible with LXD module: UNREACHABLE: Error: Instance not found

Hello :wave:

I followed the @stgraber howto here: LXD and Ansible - YouTube (which works fine)

In my case I have the same hosts.yml code as stephane BUT with an extra definition recommended by redhat on their ansible best practices. That is also usefull when using the ansible_connection: ssh instead the ansible_connection: lxd in the same playbook.

My hosts.yml is:

---

all:
  vars:
    ansible_python_interpreter: /usr/bin/python3
    ansible_connection: lxd
    ansible_user: root
    ansible_become: no
  children:
    local:
      vars:
        ansible_lxd_remote: local
        ansible_lxd_project: default
      hosts:
        c1:
          ansible_host: 10.0.1.2

In this case the ansible-playbook command failed. I have fixed this problem after I readed a same problem here: When using the `lxd` connection module, all tasks fail with `"unreachable": true` · Issue #65831 · ansible/ansible · GitHub

I have fixed that by using the ansible_host: c1 directly on all tasks in my playbook that use the ansible_connection: lxd. This override the ansible_host: 10.0.1.2 in the hosts.yml (used for ansible_connection: ssh later in my playbook)

I hope this feedback will be usefull…

1 Like