Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add markdown tables to facts #2

Open
jabelk opened this issue Jun 30, 2022 · 0 comments
Open

Add markdown tables to facts #2

jabelk opened this issue Jun 30, 2022 · 0 comments

Comments

@jabelk
Copy link
Contributor

jabelk commented Jun 30, 2022

been meaning to do this, but putting it here as a reminder for either of us

sample data using NSO sandbox:

raw_facts:
  ansible_facts:
    ansible_net_interfaces:
      GigabitEthernet1:
        bandwidth: 1000000
        description: to port7.sandbox-backend
        duplex: Full
        ipv4:
        - address: 10.10.20.176
          subnet: '24'
        lineprotocol: up
        macaddress: 5254.0015.a879
        mediatype: Virtual
        mtu: 1500
        operstatus: up
        type: CSR vNIC
      GigabitEthernet2:
        bandwidth: 1000000
        description: L3 Link to core-rtr01
        duplex: Full
        ipv4:
        - address: 172.16.252.29
          subnet: '30'
        lineprotocol: up
        macaddress: 5254.0017.9819
        mediatype: Virtual
        mtu: 1500
        operstatus: up
        type: CSR vNIC
      GigabitEthernet3:
        bandwidth: 1000000
        description: L3 Link to core-rtr02
        duplex: Full
        ipv4:
        - address: 172.16.252.33
          subnet: '30'
        lineprotocol: up
        macaddress: 5254.000b.e9cb
        mediatype: Virtual
        mtu: 1500
        operstatus: up
        type: CSR vNIC
      GigabitEthernet4:
        bandwidth: 1000000
        description: L3 Link to dist-sw01
        duplex: Full
        ipv4:
        - address: 172.16.252.6
          subnet: '30'
        lineprotocol: up
        macaddress: 5254.001b.e0af
        mediatype: Virtual
        mtu: 1500
        operstatus: up
        type: CSR vNIC
      GigabitEthernet5:
        bandwidth: 1000000
        description: L3 Link to dist-sw02
        duplex: Full
        ipv4:
        - address: 172.16.252.14
          subnet: '30'
        lineprotocol: up
        macaddress: 5254.001c.9430
        mediatype: Virtual
        mtu: 1500
        operstatus: up
        type: CSR vNIC
      GigabitEthernet6:
        bandwidth: 1000000
        description: L3 Link to dist-rtr01
        duplex: Full
        ipv4:
        - address: 172.16.252.18
          subnet: '30'
        lineprotocol: up
        macaddress: 5254.0010.994b
        mediatype: Virtual
        mtu: 1500
        operstatus: up
        type: CSR vNIC
      Loopback0:
        bandwidth: 8000000
        description: to
        duplex: null
        ipv4: []
        lineprotocol: down
        macaddress: null
        mediatype: null
        mtu: 1514
        operstatus: administratively down
        type: null
| INTERFACE | DESC | PROTOCOL | STATUS |
| ------- |------ | ------- | -------|
  {% for  iname, idata  in raw_facts['ansible_facts']['ansible_net_interfaces'].items() %}
| {{ iname }} | {{ idata.description }} | {{ idata.lineprotocol }} | {{ idata.operstatus }} |
  {% endfor %}

will create a table like this

| INTERFACE | DESC | PROTOCOL | STATUS |
| ------- |------ | ------- | -------|
  | GigabitEthernet1 | to port7.sandbox-backend | up | up |
  | GigabitEthernet2 | L3 Link to core-rtr01 | up | up |
  | GigabitEthernet3 | L3 Link to core-rtr02 | up | up |
  | GigabitEthernet4 | L3 Link to dist-sw01 | up | up |
  | GigabitEthernet5 | L3 Link to dist-sw02 | up | up |
  | GigabitEthernet6 | L3 Link to dist-rtr01 | up | up |
  | Loopback0 | to | down | administratively down |

benefit of markdown tables is they render in github/gitlab nicely and can be put in pipelines for auto-documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant