ā01-19-2021 10:06 AM
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:
Thanks
Solved! Go to Solution.
ā01-20-2021 03:23 PM
Sure Sam!
Iāve made a simple test with Ansible AWX (the test is very elementary).
My ansible file is the following:
And the setting that I use on Ansible AWX are the following:
My host that is XMC server is defined as:
My inventory file xmc is defined as follow (with the only host that rapresent my xmc server):
My project file (play.yml) is source fro github repository:
Iāve defined the credential to use for xmc :
And finally my Template is defined as follow:
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.
ā01-20-2021 03:37 PM
Wow, thank you very much for sharing all of that! Iām sure this will help quite a few people moving forward.
ā01-20-2021 03:23 PM
Sure Sam!
Iāve made a simple test with Ansible AWX (the test is very elementary).
My ansible file is the following:
And the setting that I use on Ansible AWX are the following:
My host that is XMC server is defined as:
My inventory file xmc is defined as follow (with the only host that rapresent my xmc server):
My project file (play.yml) is source fro github repository:
Iāve defined the credential to use for xmc :
And finally my Template is defined as follow:
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.
ā01-20-2021 02:55 PM
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?
ā01-19-2021 03:47 PM
Iāve solved.
Thanks