Hello all 

my tesk consist to register the number of vlan available in the device ( 
cisco switch) in a texte file 

1) I want to get just the value of vlan sotred in the item"vlan_id" 

I hope someone can help me :)


This my script 

------------------------------------------------

---
- hosts:
   - switch1

  gather_facts: yes     # on recupere les infomations acctuel sur le switch 
mais fichier ne sera pas a jour ==> on recupere les facts avant de faire 
les changements

  vars:
     ansible_connection: network_cli
     ansible_network_os: ios
     ansible_user : "cisco"
     ansible_password : "cisco"
     ansible_become: yes
     ansible_become_method: enable
     ansible_become_password: "cisco"

  tasks:
    - name: collect resources    # on a plus besoin car on a deja tous 
recuprer, j'ai deja les infomrmations dans la base de donnees
      ios_facts:
        gather_subset: all
        gather_network_resources: vlans

    - name: get all vlan configure on switch
      debug:
        msg:
         # - "{{item.key}}"
          - "{{item.value}}"
      when : '"vlan_id" in item.key'
      register: result
      with_dict: "{{ansible_network_resources.vlans.item}}"
      loop: "{{ansible_network_resources.vlans}}"


    - name: write list of vlans
      debug :
         msg : "{{ result }}"

---------------------------------------------


from this file who i gather all facts of the device and and i make 
conditions

[image: Capture.PNG] <about:invalid#zClosurez>
 

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/228cee1c-d57a-4b08-8c9a-69755e58e2c8%40googlegroups.com.

Reply via email to