cancel
Showing results for 
Search instead for 
Did you mean: 

Someone know how to use Ansible URI module to connect to the NBI of XMC?

Someone know how to use Ansible URI module to connect to the NBI of XMC?

Antonio_Opromol
Contributor II

Hi, 

someone has created an ansible playbook that connect to XMC NBI API with the ansible URI module?

 

I don’t found enough documentation on Extreme Networks API documentation that explain how to do this.

I’m able to connect with Postman with basic authentication, but I’m not able to translate the same GraphQL query in manner that works with the ansible uri module:

5939a14df5924575a9ee69da818d936b_ff45a5e4-111e-4d17-9009-3f5d7c39d643.png
5939a14df5924575a9ee69da818d936b_be4e7218-76f9-4fff-82a0-3299c8fcbbf2.png
5939a14df5924575a9ee69da818d936b_c3656cd7-5a6e-4147-97e1-491924f903eb.png

 

Thanks

1 ACCEPTED SOLUTION

Antonio_Opromol
Contributor II

Sure Sam!

I’ve made a simple test with Ansible AWX (the test is very elementary).

My ansible file is the following:

510daa4a119740e5a8d700fe63d3130c_e3c26435-2281-4a2e-a07a-e80367976fce.png

 

And the setting that I use on Ansible AWX are the following:

My host that is XMC server is defined as:

510daa4a119740e5a8d700fe63d3130c_b1ba2ea8-0a12-449c-91ca-273e3478f62f.png

My inventory file xmc is defined as follow (with the only host that rapresent my xmc server):

510daa4a119740e5a8d700fe63d3130c_fd5b37ea-05bb-4de7-b167-79d65dbc94d8.png

My project file (play.yml) is source fro github repository:

510daa4a119740e5a8d700fe63d3130c_5cb725d2-f2b4-46af-ab3d-a4ee67fc2554.png

I’ve defined the credential to use for xmc :

510daa4a119740e5a8d700fe63d3130c_57d80cb0-8aae-433e-bbcd-14ff925668f7.png

And finally my Template is defined as follow:

510daa4a119740e5a8d700fe63d3130c_aedf0690-272c-425c-bd59-1b872d8c8103.png

And the variables that I’ve defined in the template are (with the query that I want to run as GraphQL):

---
  xmc_url:
    "172.29.150.34:8443"
  username_password:
    "root:password"
  query_string:
    {"query": "query network { network { devices { id chassisId deviceData { sysDescr } } } }"}

 

And the results when I run the job is the following in my case:

SSH password: 
BECOME password[defaults to SSH password]: 

PLAY [test xmc api] ************************************************************

TASK [base64 encode using ansible] *********************************************
ok: [172.29.150.34]

TASK [Add Basic to b64encoded_data] ********************************************
ok: [172.29.150.34]

TASK [Query XMC NBI] ***********************************************************
ok: [172.29.150.34]

TASK [print result to terminal] ************************************************
ok: [172.29.150.34] => {
    "output.json.data": {
        "network": {
            "devices": [
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "VSP-8284XSQ (8.1.0.0)"
                    },
                    "id": 64
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Extreme Networks - Application Analytics Engine Virtual Appliance - PV-V - Version: 8.4.3.24"
                    },
                    "id": 70
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Extreme Networks Extreme Campus Controller - VE6120 Small,  System Version 05.06.01.0035"
                    },
                    "id": 80
                },
                {
                    "chassisId": "800614-00-14 1815N-40133",
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (X450G2-24p-G4) version 31.1.1.3 31.1.1.3 by release-manager on Sun Oct 25 17:00:38 EDT 2020"
                    },
                    "id": 83
                },
                {
                    "chassisId": "VMware-564d516f8b0244f7-21adbc8d0db5a5e0",
                    "deviceData": {
                        "sysDescr": "Extreme Fabricmgr Application - Linux-Ubuntu-16.04.5-LTS: XMC Fabricmgr Integration - Version: 8.4.3.24"
                    },
                    "id": 84
                },
                {
                    "chassisId": "",
                    "deviceData": {
                        "sysDescr": ""
                    },
                    "id": 21
                },
                {
                    "chassisId": "00:50:56:A7:10:9E",
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.7.1.1 30.7.1.1 by release-manager on Tue Jul 21 08:50:25 EDT 2020"
                    },
                    "id": 85
                },
                {
                    "chassisId": "SDNIPM624B36",
                    "deviceData": {
                        "sysDescr": "VSP-8284XSQ (8.1.0.0)"
                    },
                    "id": 86
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Extreme Networks Management Center Appliance - Version 8.5.0.169"
                    },
                    "id": 24
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (Summit-PC) version 15.4.1.3 v1541b3 by release-manager on Tue Dec 10 15:34:47 EST 2013"
                    },
                    "id": 26
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Linux demogw.demoextreme.com 2.6.18-238.19.1.el5.028stab092.2 #1 SMP Thu Jul 21 20:30:43 MSD 2011 i686"
                    },
                    "id": 28
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Linux DemoTB.demo.com 2.6.18-371.4.1.el5 #1 SMP Thu Jan 30 06:08:24 EST 2014 x86_64"
                    },
                    "id": 36
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Extreme Networks Access Control Gateway - IA-V: Virtual Access Control Engine - Version: 8.4.3.24"
                    },
                    "id": 38
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 39
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 40
                },
                {
                    "chassisId": "00:0C:29:77:C0:31",
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 41
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 42
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 43
                },
                {
                    "chassisId": "00:0C:29:53:80:BB",
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 44
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 45
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 46
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "VX9000 Wireless Controller, Version 5.8.6.0-011R MIB=01a"
                    },
                    "id": 56
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Brocade BR-SLX9540 Router, SLX Operating System Version 18r.1.00."
                    },
                    "id": 57
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Brocade BR-SLX9540 Router, SLX Operating System Version 18r.1.00."
                    },
                    "id": 58
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Brocade BR-SLX9540 Router, SLX Operating System Version 18r.1.00."
                    },
                    "id": 60
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Brocade BR-SLX9540 Router, SLX Operating System Version 18r.1.00."
                    },
                    "id": 61
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "VSP-8284XSQ (8.1.0.0)"
                    },
                    "id": 62
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "VSP-8284XSQ (8.1.0.0)"
                    },
                    "id": 63
                }
            ]
        }
    }
}

PLAY RECAP *********************************************************************
172.29.150.34              : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

 

 

I’m not an Ansible expert, so my test is very simple.

I’ve made the same tests with XOS, VOSS and XIQ, and all the API works well with Ansible AWX.

 

 

View solution in original post

4 REPLIES 4

SamPirok
Community Manager Community Manager
Community Manager

Wow, thank you very much for sharing all of that! I’m sure this will help quite a few people moving forward. 

Antonio_Opromol
Contributor II

Sure Sam!

I’ve made a simple test with Ansible AWX (the test is very elementary).

My ansible file is the following:

510daa4a119740e5a8d700fe63d3130c_e3c26435-2281-4a2e-a07a-e80367976fce.png

 

And the setting that I use on Ansible AWX are the following:

My host that is XMC server is defined as:

510daa4a119740e5a8d700fe63d3130c_b1ba2ea8-0a12-449c-91ca-273e3478f62f.png

My inventory file xmc is defined as follow (with the only host that rapresent my xmc server):

510daa4a119740e5a8d700fe63d3130c_fd5b37ea-05bb-4de7-b167-79d65dbc94d8.png

My project file (play.yml) is source fro github repository:

510daa4a119740e5a8d700fe63d3130c_5cb725d2-f2b4-46af-ab3d-a4ee67fc2554.png

I’ve defined the credential to use for xmc :

510daa4a119740e5a8d700fe63d3130c_57d80cb0-8aae-433e-bbcd-14ff925668f7.png

And finally my Template is defined as follow:

510daa4a119740e5a8d700fe63d3130c_aedf0690-272c-425c-bd59-1b872d8c8103.png

And the variables that I’ve defined in the template are (with the query that I want to run as GraphQL):

---
  xmc_url:
    "172.29.150.34:8443"
  username_password:
    "root:password"
  query_string:
    {"query": "query network { network { devices { id chassisId deviceData { sysDescr } } } }"}

 

And the results when I run the job is the following in my case:

SSH password: 
BECOME password[defaults to SSH password]: 

PLAY [test xmc api] ************************************************************

TASK [base64 encode using ansible] *********************************************
ok: [172.29.150.34]

TASK [Add Basic to b64encoded_data] ********************************************
ok: [172.29.150.34]

TASK [Query XMC NBI] ***********************************************************
ok: [172.29.150.34]

TASK [print result to terminal] ************************************************
ok: [172.29.150.34] => {
    "output.json.data": {
        "network": {
            "devices": [
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "VSP-8284XSQ (8.1.0.0)"
                    },
                    "id": 64
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Extreme Networks - Application Analytics Engine Virtual Appliance - PV-V - Version: 8.4.3.24"
                    },
                    "id": 70
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Extreme Networks Extreme Campus Controller - VE6120 Small,  System Version 05.06.01.0035"
                    },
                    "id": 80
                },
                {
                    "chassisId": "800614-00-14 1815N-40133",
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (X450G2-24p-G4) version 31.1.1.3 31.1.1.3 by release-manager on Sun Oct 25 17:00:38 EDT 2020"
                    },
                    "id": 83
                },
                {
                    "chassisId": "VMware-564d516f8b0244f7-21adbc8d0db5a5e0",
                    "deviceData": {
                        "sysDescr": "Extreme Fabricmgr Application - Linux-Ubuntu-16.04.5-LTS: XMC Fabricmgr Integration - Version: 8.4.3.24"
                    },
                    "id": 84
                },
                {
                    "chassisId": "",
                    "deviceData": {
                        "sysDescr": ""
                    },
                    "id": 21
                },
                {
                    "chassisId": "00:50:56:A7:10:9E",
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.7.1.1 30.7.1.1 by release-manager on Tue Jul 21 08:50:25 EDT 2020"
                    },
                    "id": 85
                },
                {
                    "chassisId": "SDNIPM624B36",
                    "deviceData": {
                        "sysDescr": "VSP-8284XSQ (8.1.0.0)"
                    },
                    "id": 86
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Extreme Networks Management Center Appliance - Version 8.5.0.169"
                    },
                    "id": 24
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (Summit-PC) version 15.4.1.3 v1541b3 by release-manager on Tue Dec 10 15:34:47 EST 2013"
                    },
                    "id": 26
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Linux demogw.demoextreme.com 2.6.18-238.19.1.el5.028stab092.2 #1 SMP Thu Jul 21 20:30:43 MSD 2011 i686"
                    },
                    "id": 28
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Linux DemoTB.demo.com 2.6.18-371.4.1.el5 #1 SMP Thu Jan 30 06:08:24 EST 2014 x86_64"
                    },
                    "id": 36
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Extreme Networks Access Control Gateway - IA-V: Virtual Access Control Engine - Version: 8.4.3.24"
                    },
                    "id": 38
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 39
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 40
                },
                {
                    "chassisId": "00:0C:29:77:C0:31",
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 41
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 42
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 43
                },
                {
                    "chassisId": "00:0C:29:53:80:BB",
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 44
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 45
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "ExtremeXOS (EXOS-VM) version 30.3.1.6 30.3.1.6 by release-manager on Fri Aug 30 15:00:42 EDT 2019"
                    },
                    "id": 46
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "VX9000 Wireless Controller, Version 5.8.6.0-011R MIB=01a"
                    },
                    "id": 56
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Brocade BR-SLX9540 Router, SLX Operating System Version 18r.1.00."
                    },
                    "id": 57
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Brocade BR-SLX9540 Router, SLX Operating System Version 18r.1.00."
                    },
                    "id": 58
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Brocade BR-SLX9540 Router, SLX Operating System Version 18r.1.00."
                    },
                    "id": 60
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "Brocade BR-SLX9540 Router, SLX Operating System Version 18r.1.00."
                    },
                    "id": 61
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "VSP-8284XSQ (8.1.0.0)"
                    },
                    "id": 62
                },
                {
                    "chassisId": null,
                    "deviceData": {
                        "sysDescr": "VSP-8284XSQ (8.1.0.0)"
                    },
                    "id": 63
                }
            ]
        }
    }
}

PLAY RECAP *********************************************************************
172.29.150.34              : ok=4    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

 

 

I’m not an Ansible expert, so my test is very simple.

I’ve made the same tests with XOS, VOSS and XIQ, and all the API works well with Ansible AWX.

 

 

SamPirok
Community Manager Community Manager
Community Manager

Glad you were able to resolve this! Any chance you could share the solution with us just in case someone else runs in to this in the future?

Antonio_Opromol
Contributor II

I’ve solved.

Thanks

GTM-P2G8KFN