Proxmox network interface configuration: template error while templating string: Encountered unknown tag 'item'

335 views
Skip to first unread message

Samuel Vandamme

unread,
Nov 28, 2016, 7:05:57 PM11/28/16
to Ansible Project
Hi everyone

I'm trying to setup multiple proxmox network interfaces for my containers with Ansible. 

Here is the code that I'm using. You can see in the netif property that I sometimes want to add a second interface to the container.

- name: Create instances
  proxmox: 
    vmid={{ item.id }} 
    node='simpsons' 
    api_user='{{ proxmox.api.username }}' 
    api_password='{{ proxmox.api.password }}' 
    api_host='localhost' 
    password='{{ item.hostname | b64encode | to_uuid }}' 
    hostname='{{ item.hostname }}' 
    onboot=yes
    memory={{ item.memory }}
    ostemplate='local:vztmpl/debian-8.0-standard_8.4-1_amd64.tar.gz' 
    netif='
      {"net0":"name=eth0,gw=10.100.0.1,ip=10.100.0.{{ item.id }}/24,bridge=vmbr0"}
      {% item.public_ip is defined %}
      ,
      {"net1":"name=eth1,gw=100.100.100.1,ip={{ item.public_ip }}/24,bridge=vmbr0,mac={{ item.public_mac }}"}
      {% endif %}'
  with_items: "{{ containers }}"

When I run my playbook with this task I get the following error: fatal: [xxx]: FAILED! => {"failed": true, "msg": "template error while templating string: Encountered unknown tag 'item'.. String:  {\"net0\":\"name=eth0,gw=10.100.0.1,ip=10.100.0.{{ item.id }}/24,bridge=vmbr0\"} {% item.public_ip is defined %} , {\"net1\":\"name=eth1,gw=100.100.100.1,ip={{ item.public_ip }}/24,bridge=vmbr0,mac={{ item.public_mac }}\"} {% endif %}"}

It feels like I'm taking the wrong approach to this. Can someone point me into the right direction to solve this or provide an alternative method?

ansible 2.1.2.0

Thanks a lot for your time

Reply all
Reply to author
Forward
0 new messages