0

我目前正在使用 netbox ansible 模块将接口信息从 Cisco 设备提取到 Netbox。到目前为止,我已经设法提取了接口和基本信息,例如它们的 MAC 地址。

有没有一种方法可以让您在每个端口上获取未标记和标记的 VLAN 并将它们也推送到 netbox 中?

这是我目前的 ansible 剧本:

---
- name: "PLAY 1: ADD INTERFACES TO NETBOX AND CLEANUP TEMP"
  connection: network_cli
  hosts: platforms_ios
  tags: [ ios ]
  tasks:
    - name: "TASK 1: IOS >> GET IOS FACTS"
      ios_facts:
        gather_subset: "!config"
      when: "ansible_network_os == 'ios'"

    - name: "TASK 2: NETBOX >> ADD INTERFACES TO NETBOX"
      netbox.netbox.netbox_device_interface:
        netbox_url: "<netbox url>"
        netbox_token: "<netbox_token>"
        data:
          device: "{{ inventory_hostname }}"
          name: "{{ item.key }}"
          form_factor: "{{ item.key | get_interface_type }}"
          mac_address: "{{ item.value.macaddress | convert_mac_address }}"
        state: present
      with_dict:
        - "{{ ansible_facts['net_interfaces'] }}"
      loop_control:
        label: "{{ item.key }}"

netbox.netbox.netbox_device_interface在他们的文档中untagged_vlan:有选项。tagged_vlans:但是,我不确定是否可以从 ansible 提供此信息。

4

0 回答 0