On 04. feb. 2017 20:27, czopereq76 wrote:
I am trying to add VLAN according to the last number available on the
switch. In my case right now the last VLAN number is 100 so I would like to
add next one with number 101. However running my playbook it looks like
iteration over VLAN list is not in order and playbook created VLAN 15
instead of 101.
---
- name: CHECK VLAN
hosts: eos
connection: local
tasks:
- name: CHECK FOR VLAN NUMBERS
eos_command:
commands: show vlan | json
provider: "{{ cli }}"
ignore_errors: yes
register: sh_vlan_output
- debug: var=sh_vlan_output.stdout[0].vlans.keys()
- name: SET VLAN NUMBER
set_fact:
vlan_index: "{{ item | int +1 }}"
with_items:
- "{{ sh_vlan_output.stdout[0].vlans.keys() | sort }}"
- debug: var=vlan_index
- name: VLAN NUMBER
set_fact:
vlan_index: {{ sh_vlan_output.stdout[0].vlans.keys() | map('int') |
list | max + 1 }}
This should do what you are looking for.
--
Kai Stian Olstad
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ab120568-c868-8269-ed2e-51fa622117d8%40olstad.com.
For more options, visit https://groups.google.com/d/optout.