- 14 Aug 2023
-
DarkLight
-
PDF
Managing Ansible Devices
- Updated on 14 Aug 2023
-
DarkLight
-
PDF
This page covers how to create and manage Ansible devices via GUI or API.
Create Devices
via API
Users can create an Internal device by making a POST
call to /api/2.0/devices
.
An example payload to create a device to use with Ansible is shown below.
{
"name": "csr",
"variables": {
"ansible_host": "csr.device",
"ansible_connection":"network_cli",
"ansible_network_os":"ios",
"ansible_user": "username",
"ansible_password": "password"
}
}
Users can create an Internal device group by making a POST
call to /api/2.0/groups
.
An example payload to create a group to use with Ansible is shown below.
{
"name": "group_1",
"childGroups": [
"child_group_1"
],
"devices": [
"csr"
],
"variables": {}
}
via GUI
Users can click the circled plus (+) button in the toolbar on the upper-left to start an interactive window to create a Device for Ansible.
Figure 1: Create Device
Likewise, users can click the circled plus (+) button to start an interactive window to create a Device for Ansible.
Figure 2: Create Device Group
View Devices
via API
Users can view Ansible devices by making a GET
call to /api/2.0/devices
or /api/2.0/devices/{device_name}
.
An example payload to view Ansible devices is shown below.
{
"data": [
{
"name": "csr",
"variables": {
"ansible_connection": "network_cli",
"ansible_host": "csr.device",
"ansible_network_os": "ios",
"ansible_password": "password",
"ansible_user": "username"
}
}
],
"meta": {
"count": 1,
"query_object": {
"filter": null,
"limit": null,
"offset": null,
"order": "ascending"
}
}
}
Users can view Ansible groups by making a GET
call to /api/2.0/groups
or /api/2.0/groups/{group_name}
.
An example payload to view Ansible groups is shown below.
{
"data": [
{
"childGroups": [],
"devices": [],
"name": "child_group_1",
"variables": {}
},
{
"childGroups": [
"child_group_1"
],
"devices": [
"csr"
],
"name": "group_1",
"variables": {}
}
],
"meta": {
"count": 2,
"query_object": {
"filter": null,
"limit": null,
"offset": null,
"order": "ascending"
}
}
}
via GUI
In the left navbar under Devices, you will find all the devices and groups that users have created for use with Ansible.
Figure 3: Device View
Update Devices
via API
Users can update an Internal device by making a PUT
call to /api/2.0/devices/{device_name}
.
An example payload to update the properties of an Ansible device (in this case, ansible_user
and ansible_password
) is shown below.
{
"variables": {
"ansible_host": "csr.device",
"ansible_connection": "network_cli",
"ansible_network_os": "ios",
"ansible_user": "new_username",
"ansible_password": "new_password"
}
}
Users can update an Internal device group by making a PUT
call to /api/2.0/groups/{group_name}
.
An example payload to update the properties of an Ansible device group (in this case, devices
) is shown below.
{
"name": "group_1",
"childGroups": [
"child_group_1"
],
"devices": [
"csr", "new_device"
],
"variables": {}
}
via GUI
When viewing a device, users can click the Edit button at the bottom of the page to edit the associated variables of the device.
Figure 4: Update Device
When viewing a device group, users can click the button near the Devices tab at the top to edit the devices associated with that group. Additionally, users can select the Group Variables tab and click Edit at the bottom to edit the associated variables of the group.
Figure 5: Update Device Group
Remove Devices
via API
Users can delete an Ansible device by making a DELETE
call to /api/2.0/devices/{device_name}
.
via GUI
When viewing a device, select the Delete button at the bottom of the page and then confirm the deletion.
Figure 6: Delete Device
When viewing a device group, hover the cursor over the vertically stacked dots (⋮) at the top and select Delete group from the menu that appears. Confirm the deletion.
Figure 7: Delete Device Group