Feature request: aggregate instead of loop
borgermeister opened this issue · 2 comments
borgermeister commented
Hi
Not sure if this is the correct place, but will the VLAN module in this collection support aggregated resources?
https://www.ansible.com/blog/accelerate-ansible-networking-aggregate-resources
This will speed up the creating of many VLANs.
tchiapuziowong commented
Hi @borgermeister - Development on this collection has ceased besides bug fixes , the workaround for this would be to use Jinja2 templating to generate a file with the desired configurations and using the arubaos_config
module with the src:
parameter to configure the desired VLANs in one connection. Here's an example:
- hosts: all
collections:
- arubanetworks.aos_switch
vars:
ansible_connection: network_cli
tasks:
- name: generate vlans based on template
template:
src: vlan_template.j2
dest: ./generated_vlans.txt # This is a file that would be created in your local directory
vars:
starting_vlan: 10
num_vlans: [1, 2, 3]
- name: configure vlans using template
arubaos_config:
src: ./generated_vlans.txt
Contents of vlan_template.j2
{% for vlan in num_vlans %}
{% set vlan_id = vlan + starting_vlan %}
vlan {{vlan_id}}
{% endfor %}
Contents of generated_vlans.txt:
vlan 11
vlan 12
vlan 13
borgermeister commented
I see. Thank you for the informative answer 😀