change with_dict with loop

12 views
Skip to first unread message

nbctcp

unread,
Apr 8, 2022, 5:10:09 AM4/8/22
to Ansible Project
INFO
# cat main.yml
---
- hosts: mikrotiks
  gather_facts: no
  connection: network_cli
  vars:
    ansible_network_os: routeros
    manage_firewall: true
    manage_vpn: true
    manage_wireless_interface: true
    management_subnet: 10.0.10.0/24,10.0.20.0/24,192.168.88.0/24
    vlans:
    - 10:
        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

  tasks:
    - import_tasks: coba.yml
   
# cat coba.yml
---
- name: add vlan
  routeros_command:
    commands:
    - "/interface vlan add interface=bridge1 name=VLAN-{{ item.key }} vlan-id={{ item.key }}"
  #loop: "{{ vlans|dict2items }}"
  with_dict: "{{ vlans }}"
 
PROBLEMS:
1. playbook run normally but since with_dict is deprecated
Reply all
Reply to author
Forward
0 new messages