Managing Ansible Devices
  • 14 Aug 2023
  • Dark
    Light
  • PDF

Managing Ansible Devices

  • Dark
    Light
  • PDF

Article summary

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

01_creating_device_23.1


Likewise, users can click the circled plus (+) button to start an interactive window to create a Device for Ansible.

Figure 2: Create Device Group

02_creating_device_group_23.1


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

03_viewing_devices_23.1


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

04_updating_a_device_23.1


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

05_updating_device_group_23.1


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

06_delete_device_23.1


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

07_delete_device_group_23.1


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.