Templating error for lxc_guest
edoput opened this issue · comments
During the integration test for https://github.com/LILiK-117bis/lilik_playbook/compare/setup-ca-manager-with-pip I encountered this templating error
my playbook
---
- hosts: emmett
roles:
- role: lxc_guest
vm_name: test_authorities
- role: ssh_server
ansible_connection: lxc_ssh
ansible_docker_extra_args: test_authorities
- hosts: test-authorities
roles:
- role: ca
TASK [lxc_guest : deploy container config] *************************************
fatal: [emmett]: FAILED! => {
"changed": false,
"failed": true,
"msg": "AnsibleError: Unexpected templating type error occurred on
(
lxc.include = /usr/share/lxc/config/debian.common.conf\n\nlxc.utsname = {{ vm_name }}
lxc.rootfs = /dev/{{ inventory_hostname }}vg/vm_{{ vm_name }}
lxc.tty = 4
lxc.arch = amd64
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.name = eth0
lxc.network.ipv4 = {{ hostvars | ip_from_inventory(vm_name) }}/24
lxc.network.ipv4.gateway = {{ hostvars | ip_from_inventory('vm_gateway') }}
lxc.start.auto = {% if auto_start %}1{% else %}0{% endif %}
): exceptions must be old-style classes or derived from BaseException, not type"}
Obviously is not helpful but maybe I can provide more logging
We should insert a cheking mechanism for the variables vm_name
and inventory_hostname
.
I also believe that inventory_hostname
could be replaced with ansible_hostname
as explained here
Additionally, inventory_hostname is the name of the hostname as configured in Ansible’s inventory host file. This can be useful for when you don’t want to rely on the discovered hostname ansible_hostname or for other mysterious reasons. If you have a long FQDN, inventory_hostname_short also contains the part up to the first period, without the rest of the domain.
Closed with 7eca6ef as now the filter ip_from_inventory
has some error checking