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.
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)
Late reply, Might not work but give this a try, anyone reading this
Just made this account to say BIG THANK YOU to ZeroGravitas. YOU ARE SO AWESOME i was having trouble with: "Ansible_loop_var attribute error: nonetype object has no attribute items" leading to lxd_container " error when installing xroad using ansible playbook
Here’s the log
line 99, in _ansiballz_main invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/vboxuser/.ansible/tmp/ansible-tmp-1728036128.1841958-3528-12931979 1180256/Ansiballz_lxd_container.py", line 47, in invoke_module runpy.run_module(mod_name='ansible_collections.community.general.plugins.mod
ules.lxd_container', init_globals-dict(_module_fqn='ansible_collections.communit y.general.plugins.modules.lxd_container', _modlib_path=modlib_path), File "/usr/lib/python3.10/runpy.py", line 224, in run_module return _run_module_code(code, init_globals, run_name, mod_spec) File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code _run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals)
File "/tmp/ansible_lxd_container_payload_g1eotpsb/ansible_lxd_container_payloa d.zip/ansible_collections/community/general/plugins/modules/lxd_container.py", l ine 901, in <module>