I’m using ansible to configure ports on my Juniper switches where I use LACP to configure an aggregation of ports from a server on two different switches, where eth0 will be connected to switch 01 and eth1 to switch 02
I created a template for configuring the interfaces, which follows below:
interfaces {
xe-0/0/{{ id_interface }} {
description “{{ interface_descricao }}”;
ether-options {
802.3ad ae{{ id_ae_interface }};
}
}
}
Inside the main.yml file that is in the vars directory, I insert the variables to populate the fields
interface_id: 30
id_ae_interface: 23
interface_description: eth0-VMHOST422
Here comes my question/problem, as I mentioned before, I need to configure the eth0 port and the eth1 port, where the eth0 port goes on switch 01 and the eth1 port on switch 02, is there any way to make it possible to populate the variables with eth0 and eth1 port in just one run?
Or if anyone has experienced this and solved it in some other way, I would be grateful for the help.
Away from my lab but knee-jerk is that group-vars should allow you to organize that information.
Hi Andrew
Thanks for the tip, it was spot on.
I created the group_vars directory and the qfx.yml file that looks like this:
qfx:
qfx01:
- {‘name’: ‘xe-0/0/40’, ‘description’: ‘eth0-VMHOST-TESTE’}
- {‘ae’: ‘ae45’, ‘members’: ‘xe-0/0/40’}
qfx2:
- {‘name’: ‘xe-0/0/40’, ‘description’: ‘eth1-VMHOST-TESTE’}
And my tasks were like this, executing the generated loop and with a conditional in the execution
- name: Configurando interfaces nos switches
junipernetworks.junos.junos_interfaces:
config:
- name: “{{ item.name }}”
description: “{{ item.description }}”
loop: “{{ qfx[inventory_hostname] }}”
when: item.name is defined
tags:
- loop-interface
- name: Configurando interfaces ae’s nas interfaces dos switches
junipernetworks.junos.junos_lag_interfaces:
config:
- name: “{{ item.ae }}”
members:
- member: “{{ item.members }}”
loop: “{{ qfx[inventory_hostname] }}”
when: item.ae is defined
tags:
- loop-ae
Again, thank you very much.