jeisenbath / ansible-collection-solarwinds-orion

An Ansible collection for managing nodes in Solarwinds Orion
10 stars 1 forks source link

Adding Interface Matches all interface that match that Name #4

Closed Andyjb8 closed 8 months ago

Andyjb8 commented 11 months ago

I having an issue with the orion_node_interface module. When I attempt to add an interface to monitor using the below task (in this example adding "ge-0/0/1") it adds monitoring to all the interfaces that have "ge-0/0/1" in the name, including ge-0/0/10, ge-0/0/11, ge-0/0/12, ge-0/0/13. etc... I want to ONLY add interface ge-0/0/1. Is there a way to resolve this

Andyjb8 commented 11 months ago

I tested changing line 230 in orion.py and it worked as I wanted it to.

Changed this:      if re.search(interface_name, x['Caption'])

To this:     if interface_name == x['Caption']

jeisenbath commented 11 months ago

Using the regex matching was to facilitate adding interfaces to Windows servers, since at least in my environment the interfaces get discovered by SNMP with their manufacturer's name and a bunch of other details. I did not anticipate the issue you have, will try to work on some additional logic (potentially try exact match first, if it doesn't return exact match then try pattern match).

jeisenbath commented 11 months ago

@Andyjb8 I have pushed v1.0.2 that supports exact matching first, then regex matching second. This should suit both of our needs, but I don't have a node to test it on. Let me know if it's not working for you, and I will take a different approach.

Andyjb8 commented 10 months ago

I updated to version 1.0.3 and this is not working as expected. When running this task to add GigabitEthernet3, it also adds all other interfaces that include "GigabitEthernet3" For instance in my lab it adds "GigabitEthernet3.100" and "GigabitEthernet3.101" as well. So it doesn't look like the exact matching first is working right.

    - name: Add interface to node
      solarwinds.orion.orion_node_interface:
        <<: *solarwinds_info
        name: "{{ inventory_hostname }}"
        interface: "GigabitEthernet3"
        state: present
      delegate_to: localhost

Here is the debug output. It only shows "GigabitEthernet3" but when I go to list resources of the node in solarwinds, it adds monitoring for all the interfaces that include "GigabitEthernet3", like "GigabitEthernet3.100" and "GigabitEthernet3.101.

changed: [rtr-01 -> localhost] => { "changed": true, "invocation": { "module_args": { "hostname": "solarwinds_hostname", "interface": "GigabitEthernet3", "ip_address": null, "name": "rtr-01", "node_id": null, "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "state": "present", "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" } }, "orion_node": { "caption": "rtr-01", "ipaddress": "10.x.x.x", "netobjectid": "N:1062", "nodeid": 1062, "objectsubtype": "SNMP", "status": 1, "statusdescription": "Node status is Up.", "unmanaged": false, "unmanagefrom": "1899-12-30T00:00:00+00:00", "unmanageuntil": "1899-12-30T00:00:00+00:00", "uri": "swis://solarwinds_hostname/Orion/Orion.Nodes/NodeID=1062" } }

jeisenbath commented 10 months ago

Do you have an interface named only GigabitEthernet3, or do they all have appended values like .100? If you only pass GigabitEthernet3.100 does it work to only add it?

Either way, I think it's more transparent if I add a param to enable pattern matching, based on your feedback.

Andyjb8 commented 10 months ago

Yes, if I only pass GigabitEthernet3.100 it only adds GigabitEthernet3.100 and not other interfaces such as GigabitEthernet3.200 or GigabitEthernet3.

jeisenbath commented 9 months ago

Just pushed out 1.0.4 with a major change that makes the pattern matching explicit. If you don't set the param regex to True now, you won't get extra interfaces added.

Andyjb8 commented 8 months ago

I am still having an issue with this and just hadn't gotten around to dig into testing it until now. 1.0.4 does not work for me at all. From my ansible output perspective, it appears to work successfully, but when I go into solarwinds it doesn't actually add any interfaces to monitoring. When I roll back to 1.0.3 and run my same playbook, it successfully adds interfaces, but it also adds all the sub interfaces I do not want to monitor. It if I add this line:

discovered_interface = [x for x in discovered_interface if not '.' in x['Caption']]

To orion.py in 1.0.4 as shown below if behaves as I expected and adds only the interfaces I specified and not the sub interfaces.

def add_interface(self, node, interface_name, regex):
        discovered_interfaces = self.discover_interfaces(node)
        if regex:
            discovered_interface = [
                x for x
                in discovered_interfaces
                if re.search(interface_name, x['Caption'])
            ]
        else:
            discovered_interface = [
                x for x
                in discovered_interfaces
                if interface_name == x['Caption']
            ]
        discovered_interface = [x for x in discovered_interface if not '.' in x['Caption']] ### ADDED THIS LINE ###
        if discovered_interface:
            self.swis.invoke('Orion.NPM.Interfaces', 'AddInterfacesOnNode', node['nodeid'], discovered_interface, 'AddDefaultPollers')

Is this fix something you can add to the next version? Thanks for all your work on this collection!

jeisenbath commented 8 months ago

Hmm, can you clarify again the issue for me then. Some details I'm looking for are the params for the task you are passing, and a list of all interfaces on the node. Your solution may not work for someone that does want to add interfaces with a '.' in the interface name, so we'll need to work on a different solution.

Andyjb8 commented 8 months ago

Here is the task in my playbook that loops through the interfaces I have identified I want to monitor.

- name: ADD INTERFACES TO SOLARWINDS TO MONITOR
  solarwinds.orion.orion_node_interface:
    <<: *solarwinds_info
    name: "{{ inventory_hostname }}"
    state: present
    interface: "{{ item }}"
    regex: true
  loop: "{{ monitor_interfaces }}"
  delegate_to: localhost

Ok here is what I get when I run the playbook and it appears to work from perspective of Ansible, but it doesn't actually add the interfaces in SolarWinds to monitor.

TASK [DEBUG monitor_interfaces] *****************************************************************************************************************************
task path: /home/admin/automation/playbooks/solarwinds/orion_add_interface2.yml:169
Friday 27 October 2023  13:51:12 +0000 (0:00:00.154)       0:00:41.651 ********
redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
ok: [XX-RT-02] => {
    "monitor_interfaces": [
        "GigabitEthernet1",
        "GigabitEthernet2",
        "GigabitEthernet3",
        "GigabitEthernet4",
        "GigabitEthernet5",
        "Tunnel20",
        "Tunnel21"
    ]
}

TASK [ADD INTERFACES TO SOLARWINDS TO MONITOR] **************************************************************************************************************
task path: /home/admin/automation/playbooks/solarwinds/orion_add_interface2.yml:174
Friday 27 October 2023  13:51:13 +0000 (0:00:01.033)       0:00:42.684 ********
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: admin
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698414674.1549666-47257-70406198132439 `" && echo ansible-tmp-1698414674.1549666-47257-70406198132439="` echo /home/admin/.ansible/tmp/ansible-tmp-1698414674.1549666-47257-70406198132439 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-47190xlc6pj50/tmpo4wyiclu TO /home/admin/.ansible/tmp/ansible-tmp-1698414674.1549666-47257-70406198132439/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698414674.1549666-47257-70406198132439/ /home/admin/.ansible/tmp/ansible-tmp-1698414674.1549666-47257-70406198132439/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698414674.1549666-47257-70406198132439/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698414674.1549666-47257-70406198132439/ > /dev/null 2>&1 && sleep 0'
changed: [XX-RT-02 -> localhost] => (item=GigabitEthernet1) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "GigabitEthernet1",
            "ip_address": null,
            "name": "XX-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet1",
    "orion_node": {
        "caption": "XX-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698414679.865266-47257-66904311906934 `" && echo ansible-tmp-1698414679.865266-47257-66904311906934="` echo /home/admin/.ansible/tmp/ansible-tmp-1698414679.865266-47257-66904311906934 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-47190xlc6pj50/tmpzniqq73a TO /home/admin/.ansible/tmp/ansible-tmp-1698414679.865266-47257-66904311906934/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698414679.865266-47257-66904311906934/ /home/admin/.ansible/tmp/ansible-tmp-1698414679.865266-47257-66904311906934/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698414679.865266-47257-66904311906934/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698414679.865266-47257-66904311906934/ > /dev/null 2>&1 && sleep 0'
changed: [XX-RT-02 -> localhost] => (item=GigabitEthernet2) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "GigabitEthernet2",
            "ip_address": null,
            "name": "XX-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet2",
    "orion_node": {
        "caption": "XX-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698414685.0201523-47257-274582594039833 `" && echo ansible-tmp-1698414685.0201523-47257-274582594039833="` echo /home/admin/.ansible/tmp/ansible-tmp-1698414685.0201523-47257-274582594039833 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-47190xlc6pj50/tmpa7_sgnup TO /home/admin/.ansible/tmp/ansible-tmp-1698414685.0201523-47257-274582594039833/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698414685.0201523-47257-274582594039833/ /home/admin/.ansible/tmp/ansible-tmp-1698414685.0201523-47257-274582594039833/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698414685.0201523-47257-274582594039833/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698414685.0201523-47257-274582594039833/ > /dev/null 2>&1 && sleep 0'
changed: [XX-RT-02 -> localhost] => (item=GigabitEthernet3) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "GigabitEthernet3",
            "ip_address": null,
            "name": "XX-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet3",
    "orion_node": {
        "caption": "XX-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698414690.0818663-47257-226811820388281 `" && echo ansible-tmp-1698414690.0818663-47257-226811820388281="` echo /home/admin/.ansible/tmp/ansible-tmp-1698414690.0818663-47257-226811820388281 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-47190xlc6pj50/tmpsdtxue0u TO /home/admin/.ansible/tmp/ansible-tmp-1698414690.0818663-47257-226811820388281/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698414690.0818663-47257-226811820388281/ /home/admin/.ansible/tmp/ansible-tmp-1698414690.0818663-47257-226811820388281/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698414690.0818663-47257-226811820388281/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698414690.0818663-47257-226811820388281/ > /dev/null 2>&1 && sleep 0'
changed: [XX-RT-02 -> localhost] => (item=GigabitEthernet4) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "GigabitEthernet4",
            "ip_address": null,
            "name": "XX-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet4",
    "orion_node": {
        "caption": "XX-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698414695.0813525-47257-108817827907438 `" && echo ansible-tmp-1698414695.0813525-47257-108817827907438="` echo /home/admin/.ansible/tmp/ansible-tmp-1698414695.0813525-47257-108817827907438 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-47190xlc6pj50/tmp2motgain TO /home/admin/.ansible/tmp/ansible-tmp-1698414695.0813525-47257-108817827907438/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698414695.0813525-47257-108817827907438/ /home/admin/.ansible/tmp/ansible-tmp-1698414695.0813525-47257-108817827907438/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698414695.0813525-47257-108817827907438/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698414695.0813525-47257-108817827907438/ > /dev/null 2>&1 && sleep 0'
changed: [XX-RT-02 -> localhost] => (item=GigabitEthernet5) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "GigabitEthernet5",
            "ip_address": null,
            "name": "XX-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet5",
    "orion_node": {
        "caption": "XX-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698414700.0942972-47257-87886742477751 `" && echo ansible-tmp-1698414700.0942972-47257-87886742477751="` echo /home/admin/.ansible/tmp/ansible-tmp-1698414700.0942972-47257-87886742477751 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-47190xlc6pj50/tmphi6qastv TO /home/admin/.ansible/tmp/ansible-tmp-1698414700.0942972-47257-87886742477751/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698414700.0942972-47257-87886742477751/ /home/admin/.ansible/tmp/ansible-tmp-1698414700.0942972-47257-87886742477751/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698414700.0942972-47257-87886742477751/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698414700.0942972-47257-87886742477751/ > /dev/null 2>&1 && sleep 0'
changed: [XX-RT-02 -> localhost] => (item=Tunnel20) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "Tunnel20",
            "ip_address": null,
            "name": "XX-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "Tunnel20",
    "orion_node": {
        "caption": "XX-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698414705.2717566-47257-119175839041621 `" && echo ansible-tmp-1698414705.2717566-47257-119175839041621="` echo /home/admin/.ansible/tmp/ansible-tmp-1698414705.2717566-47257-119175839041621 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-47190xlc6pj50/tmpkethovrc TO /home/admin/.ansible/tmp/ansible-tmp-1698414705.2717566-47257-119175839041621/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698414705.2717566-47257-119175839041621/ /home/admin/.ansible/tmp/ansible-tmp-1698414705.2717566-47257-119175839041621/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698414705.2717566-47257-119175839041621/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698414705.2717566-47257-119175839041621/ > /dev/null 2>&1 && sleep 0'
changed: [XX-RT-02 -> localhost] => (item=Tunnel21) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "Tunnel21",
            "ip_address": null,
            "name": "XX-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "Tunnel21",
    "orion_node": {
        "caption": "XX-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>/Orion/Orion.Nodes/NodeID=1062"
    }
}

PLAY RECAP **************************************************************************************************************************************************
XX-RT-02                   : ok=8    changed=1    unreachable=0    failed=0    skipped=16   rescued=0    ignored=0
jeisenbath commented 8 months ago

Ah, so you are setting regex to true, which you shouldn't want to do if you want only exact name matching.

Andyjb8 commented 8 months ago

I think that got left in there when I was testing, but commenting it out out does not fix it.

I commented out the line in orion.py that I added: # discovered_interface = [x for x in discovered_interface if not '.' in x['Caption']]

And commented out regex: true in my task:

    - name: ADD INTERFACES TO SOLARWINDS TO MONITOR
      solarwinds.orion.orion_node_interface:
        <<: *solarwinds_info
        name: "{{ inventory_hostname }}"
        state: present
        interface: "{{ item }}"
#        regex: true
      loop: "{{ monitor_interfaces }}"
      delegate_to: localhost

Here is output when I run playbook, it still isn't adding the intefaces solarwinds.

image

TASK [DEBUG monitor_interfaces] *****************************************************************************************************************************
task path: /home/admin/automation/playbooks/solarwinds/orion_add_interface2.yml:169
Friday 27 October 2023  18:59:10 +0000 (0:00:00.094)       0:00:37.212 ********
redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
ok: [xx-RT-02] => {
    "monitor_interfaces": [
        "GigabitEthernet1",
        "GigabitEthernet2",
        "GigabitEthernet3",
        "GigabitEthernet4",
        "GigabitEthernet5",
        "Tunnel20",
        "Tunnel21"
    ]
}

TASK [ADD INTERFACES TO SOLARWINDS TO MONITOR] **************************************************************************************************************
task path: /home/admin/automation/playbooks/solarwinds/orion_add_interface2.yml:174
Friday 27 October 2023  18:59:11 +0000 (0:00:01.205)       0:00:38.418 ********
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: admin
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698433151.9453392-54732-215351004724895 `" && echo ansible-tmp-1698433151.9453392-54732-215351004724895="` echo /home/admin/.ansible/tmp/ansible-tmp-1698433151.9453392-54732-215351004724895 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-546655w2mhb2p/tmpgktw59h7 TO /home/admin/.ansible/tmp/ansible-tmp-1698433151.9453392-54732-215351004724895/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698433151.9453392-54732-215351004724895/ /home/admin/.ansible/tmp/ansible-tmp-1698433151.9453392-54732-215351004724895/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698433151.9453392-54732-215351004724895/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698433151.9453392-54732-215351004724895/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=GigabitEthernet1) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<solarwinds_server>",
            "interface": "GigabitEthernet1",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet1",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "10.100.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698433166.4580915-54732-92844972180152 `" && echo ansible-tmp-1698433166.4580915-54732-92844972180152="` echo /home/admin/.ansible/tmp/ansible-tmp-1698433166.4580915-54732-92844972180152 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-546655w2mhb2p/tmpkmn1xmm1 TO /home/admin/.ansible/tmp/ansible-tmp-1698433166.4580915-54732-92844972180152/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698433166.4580915-54732-92844972180152/ /home/admin/.ansible/tmp/ansible-tmp-1698433166.4580915-54732-92844972180152/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698433166.4580915-54732-92844972180152/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698433166.4580915-54732-92844972180152/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=GigabitEthernet2) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<solarwinds_server>",
            "interface": "GigabitEthernet2",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet2",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "10.100.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698433171.3951383-54732-147120747157055 `" && echo ansible-tmp-1698433171.3951383-54732-147120747157055="` echo /home/admin/.ansible/tmp/ansible-tmp-1698433171.3951383-54732-147120747157055 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-546655w2mhb2p/tmp37ydlct7 TO /home/admin/.ansible/tmp/ansible-tmp-1698433171.3951383-54732-147120747157055/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698433171.3951383-54732-147120747157055/ /home/admin/.ansible/tmp/ansible-tmp-1698433171.3951383-54732-147120747157055/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698433171.3951383-54732-147120747157055/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698433171.3951383-54732-147120747157055/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=GigabitEthernet3) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<solarwinds_server>",
            "interface": "GigabitEthernet3",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet3",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "10.100.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698433176.4563475-54732-243008303605263 `" && echo ansible-tmp-1698433176.4563475-54732-243008303605263="` echo /home/admin/.ansible/tmp/ansible-tmp-1698433176.4563475-54732-243008303605263 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-546655w2mhb2p/tmpijo26z2l TO /home/admin/.ansible/tmp/ansible-tmp-1698433176.4563475-54732-243008303605263/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698433176.4563475-54732-243008303605263/ /home/admin/.ansible/tmp/ansible-tmp-1698433176.4563475-54732-243008303605263/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698433176.4563475-54732-243008303605263/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698433176.4563475-54732-243008303605263/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=GigabitEthernet4) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<solarwinds_server>",
            "interface": "GigabitEthernet4",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet4",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "10.100.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698433181.4006205-54732-217308363309503 `" && echo ansible-tmp-1698433181.4006205-54732-217308363309503="` echo /home/admin/.ansible/tmp/ansible-tmp-1698433181.4006205-54732-217308363309503 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-546655w2mhb2p/tmpe07_15f8 TO /home/admin/.ansible/tmp/ansible-tmp-1698433181.4006205-54732-217308363309503/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698433181.4006205-54732-217308363309503/ /home/admin/.ansible/tmp/ansible-tmp-1698433181.4006205-54732-217308363309503/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698433181.4006205-54732-217308363309503/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698433181.4006205-54732-217308363309503/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=GigabitEthernet5) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<solarwinds_server>",
            "interface": "GigabitEthernet5",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet5",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "10.100.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698433187.5093615-54732-173753113721157 `" && echo ansible-tmp-1698433187.5093615-54732-173753113721157="` echo /home/admin/.ansible/tmp/ansible-tmp-1698433187.5093615-54732-173753113721157 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-546655w2mhb2p/tmpsjdgam8j TO /home/admin/.ansible/tmp/ansible-tmp-1698433187.5093615-54732-173753113721157/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698433187.5093615-54732-173753113721157/ /home/admin/.ansible/tmp/ansible-tmp-1698433187.5093615-54732-173753113721157/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698433187.5093615-54732-173753113721157/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698433187.5093615-54732-173753113721157/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=Tunnel20) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<solarwinds_server>",
            "interface": "Tunnel20",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "Tunnel20",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "10.100.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698433192.6433632-54732-259474749663694 `" && echo ansible-tmp-1698433192.6433632-54732-259474749663694="` echo /home/admin/.ansible/tmp/ansible-tmp-1698433192.6433632-54732-259474749663694 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-546655w2mhb2p/tmpn7hwgwwu TO /home/admin/.ansible/tmp/ansible-tmp-1698433192.6433632-54732-259474749663694/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698433192.6433632-54732-259474749663694/ /home/admin/.ansible/tmp/ansible-tmp-1698433192.6433632-54732-259474749663694/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698433192.6433632-54732-259474749663694/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698433192.6433632-54732-259474749663694/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=Tunnel21) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<solarwinds_server>",
            "interface": "Tunnel21",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": false,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "Tunnel21",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "10.100.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<solarwinds_server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
Andyjb8 commented 8 months ago

But when I have this in my orion.py

discovered_interface = [x for x in discovered_interface if not '.' in x['Caption']] # ADDED

and have the regex: true in my task like I had in above comment, it works.

image

TASK [DEBUG monitor_interfaces] *****************************************************************************************************************************
task path: /home/admin/automation/playbooks/solarwinds/orion_add_interface2.yml:169
Friday 27 October 2023  19:15:47 +0000 (0:00:00.157)       0:00:41.620 ********
redirecting (type: terminal) ansible.builtin.ios to cisco.ios.ios
redirecting (type: cliconf) ansible.builtin.ios to cisco.ios.ios
ok: [xx-RT-02] => {
    "monitor_interfaces": [
        "GigabitEthernet1",
        "GigabitEthernet2",
        "GigabitEthernet3",
        "GigabitEthernet4",
        "GigabitEthernet5",
        "Tunnel20",
        "Tunnel21"
    ]
}

TASK [ADD INTERFACES TO SOLARWINDS TO MONITOR] **************************************************************************************************************
task path: /home/admin/automation/playbooks/solarwinds/orion_add_interface2.yml:174
Friday 27 October 2023  19:15:48 +0000 (0:00:01.004)       0:00:42.625 ********
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: admin
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698434148.337567-55212-55174933646734 `" && echo ansible-tmp-1698434148.337567-55212-55174933646734="` echo /home/admin/.ansible/tmp/ansible-tmp-1698434148.337567-55212-55174933646734 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-55145jnzc6q1a/tmpbyb68s_b TO /home/admin/.ansible/tmp/ansible-tmp-1698434148.337567-55212-55174933646734/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698434148.337567-55212-55174933646734/ /home/admin/.ansible/tmp/ansible-tmp-1698434148.337567-55212-55174933646734/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698434148.337567-55212-55174933646734/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698434148.337567-55212-55174933646734/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=GigabitEthernet1) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "GigabitEthernet1",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": true,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet1",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698434159.3254302-55212-58223343580683 `" && echo ansible-tmp-1698434159.3254302-55212-58223343580683="` echo /home/admin/.ansible/tmp/ansible-tmp-1698434159.3254302-55212-58223343580683 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-55145jnzc6q1a/tmpx3hgn9o_ TO /home/admin/.ansible/tmp/ansible-tmp-1698434159.3254302-55212-58223343580683/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698434159.3254302-55212-58223343580683/ /home/admin/.ansible/tmp/ansible-tmp-1698434159.3254302-55212-58223343580683/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698434159.3254302-55212-58223343580683/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698434159.3254302-55212-58223343580683/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=GigabitEthernet2) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "GigabitEthernet2",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": true,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet2",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698434169.4602582-55212-108649768080731 `" && echo ansible-tmp-1698434169.4602582-55212-108649768080731="` echo /home/admin/.ansible/tmp/ansible-tmp-1698434169.4602582-55212-108649768080731 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-55145jnzc6q1a/tmp62e4spm4 TO /home/admin/.ansible/tmp/ansible-tmp-1698434169.4602582-55212-108649768080731/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698434169.4602582-55212-108649768080731/ /home/admin/.ansible/tmp/ansible-tmp-1698434169.4602582-55212-108649768080731/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698434169.4602582-55212-108649768080731/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698434169.4602582-55212-108649768080731/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=GigabitEthernet3) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "GigabitEthernet3",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": true,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet3",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698434180.5956469-55212-250349614301301 `" && echo ansible-tmp-1698434180.5956469-55212-250349614301301="` echo /home/admin/.ansible/tmp/ansible-tmp-1698434180.5956469-55212-250349614301301 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-55145jnzc6q1a/tmpa7om2u54 TO /home/admin/.ansible/tmp/ansible-tmp-1698434180.5956469-55212-250349614301301/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698434180.5956469-55212-250349614301301/ /home/admin/.ansible/tmp/ansible-tmp-1698434180.5956469-55212-250349614301301/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698434180.5956469-55212-250349614301301/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698434180.5956469-55212-250349614301301/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=GigabitEthernet4) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "GigabitEthernet4",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": true,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet4",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698434190.495043-55212-227794611164293 `" && echo ansible-tmp-1698434190.495043-55212-227794611164293="` echo /home/admin/.ansible/tmp/ansible-tmp-1698434190.495043-55212-227794611164293 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-55145jnzc6q1a/tmp7_6xhvkt TO /home/admin/.ansible/tmp/ansible-tmp-1698434190.495043-55212-227794611164293/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698434190.495043-55212-227794611164293/ /home/admin/.ansible/tmp/ansible-tmp-1698434190.495043-55212-227794611164293/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698434190.495043-55212-227794611164293/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698434190.495043-55212-227794611164293/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=GigabitEthernet5) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "GigabitEthernet5",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": true,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "GigabitEthernet5",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698434200.849572-55212-106970718924919 `" && echo ansible-tmp-1698434200.849572-55212-106970718924919="` echo /home/admin/.ansible/tmp/ansible-tmp-1698434200.849572-55212-106970718924919 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-55145jnzc6q1a/tmphrr6c0hg TO /home/admin/.ansible/tmp/ansible-tmp-1698434200.849572-55212-106970718924919/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698434200.849572-55212-106970718924919/ /home/admin/.ansible/tmp/ansible-tmp-1698434200.849572-55212-106970718924919/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698434200.849572-55212-106970718924919/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698434200.849572-55212-106970718924919/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=Tunnel20) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "Tunnel20",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": true,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "Tunnel20",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
<localhost> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1698434210.9536035-55212-72945728529576 `" && echo ansible-tmp-1698434210.9536035-55212-72945728529576="` echo /home/admin/.ansible/tmp/ansible-tmp-1698434210.9536035-55212-72945728529576 `" ) && sleep 0'
Using module file /home/admin/automation/collections/ansible_collections/solarwinds/orion/plugins/modules/orion_node_interface.py
<localhost> PUT /home/admin/.ansible/tmp/ansible-local-55145jnzc6q1a/tmp50f33fh_ TO /home/admin/.ansible/tmp/ansible-tmp-1698434210.9536035-55212-72945728529576/AnsiballZ_orion_node_interface.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1698434210.9536035-55212-72945728529576/ /home/admin/.ansible/tmp/ansible-tmp-1698434210.9536035-55212-72945728529576/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1698434210.9536035-55212-72945728529576/AnsiballZ_orion_node_interface.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1698434210.9536035-55212-72945728529576/ > /dev/null 2>&1 && sleep 0'
changed: [xx-RT-02 -> localhost] => (item=Tunnel21) => {
    "ansible_loop_var": "item",
    "changed": true,
    "invocation": {
        "module_args": {
            "hostname": "<server>",
            "interface": "Tunnel21",
            "ip_address": null,
            "name": "xx-RT-02",
            "node_id": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "regex": true,
            "state": "present",
            "username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER"
        }
    },
    "item": "Tunnel21",
    "orion_node": {
        "caption": "xx-RT-02",
        "ipaddress": "x.x.0.2",
        "netobjectid": "N:1062",
        "nodeid": 1062,
        "objectsubtype": "SNMP",
        "status": 1,
        "statusdescription": "Node status is Up.",
        "unmanaged": false,
        "unmanagefrom": "1899-12-30T00:00:00+00:00",
        "unmanageuntil": "1899-12-30T00:00:00+00:00",
        "uri": "swis://<server>.automation.lab/Orion/Orion.Nodes/NodeID=1062"
    }
}
jeisenbath commented 8 months ago

Ok I think I see the issue now.

You should either pass exactly the interface name with regex: false ("GigabitEthernet1 - Gi1") or come up with a regex pattern to exclude the interfaces you don't want and use regex: true. Example regex that may work is "GigabitEthernet1\s" where \s is the regex for whitespace.

Andyjb8 commented 8 months ago

I am passing the the exact interface name as it is named on my Cisco router "GigabitEthernet1", but now I see that Solarwinds sees the interfaces names differently and is adding a shorted name "- Gi1" to end. Also, on Juniper devices, the list resources list of interfaces appends the interfaces description to the interface name, so I am having the same problem, but if the interface is missing a description it successfully adds it. I will do some testing to see if I can make a regex work for the interfaces I am trying to add.

jeisenbath commented 8 months ago

Sounds good, yeah that disconnect between how the interface is named on the device versus how SNMP polls the device is the exact reason I needed regex support. Windows interfaces get the driver/device manufacturer included in the name when SNMP polls it for Solarwinds, so "Ethernet 1" becomes something like "Realtek PCIe GBE Family Controller #2 · Ethernet 1". If in your testing you come up with better examples or clearer documentation to add to the module, feel free to make a PR. Thanks!