INFO
# cat main.yml
---
- hosts: mikrotiks
vlans:
- 10:
interfaces:
- ether3
- ether4
untagged_interfaces: ether2
tagged_interfaces: bridge1,ether3,ether4
network: 10.0.10.0
netmask: 24
ip_address1: 10.0.10.1
ip_address2: 10.0.10.2
dns: 192.168.88.1
dhcp_pool1: 10.0.10.101-10.0.10.150
dhcp_pool2: 10.0.10.151-10.0.10.200
leasetime: 1d
- 20:
interfaces:
- ether3
- ether4
untagged_interfaces: ether2
tagged_interfaces: bridge1,ether3,ether4
network: 10.0.20.0
netmask: 24
ip_address1: 10.0.20.1
ip_address2: 10.0.20.2
dns: 192.168.88.1
dhcp_pool1: 10.0.20.101-10.0.20.150
dhcp_pool2: 10.0.20.151-10.0.20.200
leasetime: 1d
# cat coba.yml
- name: add vlan
debug:
msg: "print {{ item.key }}"
with_dict: "{{vlans}}"
PROBLEMS:
1. when I run playbook it will print
10
interfaces
untagged_interfaces
...
leasetime
GOALS:
1. get only first occurrence
I modify the playbook coba.yml
msg: "print {{ item.key[0] }}"
or
msg: "print {{ item.key|first }}"
or
msg: "print "{{ item.0.keys()|first }}"
but got this error
fatal: [R1]: FAILED! => {
"msg": "The task includes an option with an undefined variable. The
error was: dict object has no element 0\n\nThe error appears to be in
'/root/mikrotik/coba.yml': line 5, column 49, but may\nbe elsewhere in the
file depending on the exact syntax problem.\n\nThe offending line appears
to be:\n\n# - \"/interface bridge add ingress-filtering=no name=bridge1
vlan-filtering=yes\"\n ^
here\n\nThere appears to be both 'k=v' shorthand syntax and YAML in this
task. Only one syntax may be used.\n
?
1. how to fix that
tq
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/37a15756-ae7d-4baf-a28c-8b57e1bfbe19n%40googlegroups.com.