Create and manage devices

Information and examples on how to create and manage devices via GUI or API are provided here.

Create devices

Via API

You 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.

1{
2"name": "csr",
3 "variables": {
4 "ansible_host": "csr.device",
5 "ansible_connection":"network_cli",
6 "ansible_network_os":"ios",
7 "ansible_user": "username",
8 "ansible_password": "password"
9 }
10}

You 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.

1{
2 "name": "group_1",
3 "childGroups": [
4 "child_group_1"
5 ],
6 "devices": [
7 "csr"
8 ],
9 "variables": {}
10}

Via GUI

You can click the circled plus (+) button in the toolbar on the upper-left to start an interactive window to create a Device for Ansible.

Create device

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

Create device group

View devices

Via API

You 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.

1{
2 "data": [
3 {
4 "name": "csr",
5 "variables": {
6 "ansible_connection": "network_cli",
7 "ansible_host": "csr.device",
8 "ansible_network_os": "ios",
9 "ansible_password": "password",
10 "ansible_user": "username"
11 }
12 }
13 ],
14 "meta": {
15 "count": 1,
16 "query_object": {
17 "filter": null,
18 "limit": null,
19 "offset": null,
20 "order": "ascending"
21 }
22 }
23}

You 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.

1{
2 "data": [
3 {
4 "childGroups": [],
5 "devices": [],
6 "name": "child_group_1",
7 "variables": {}
8 },
9 {
10 "childGroups": [
11 "child_group_1"
12 ],
13 "devices": [
14 "csr"
15 ],
16 "name": "group_1",
17 "variables": {}
18 }
19 ],
20 "meta": {
21 "count": 2,
22 "query_object": {
23 "filter": null,
24 "limit": null,
25 "offset": null,
26 "order": "ascending"
27 }
28 }
29}

Via GUI

In the left navbar under Devices, you will find all the devices and groups you have created for use with Ansible.

Device view

Update devices

Via API

You 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.

1{
2 "variables": {
3 "ansible_host": "csr.device",
4 "ansible_connection": "network_cli",
5 "ansible_network_os": "ios",
6 "ansible_user": "new_username",
7 "ansible_password": "new_password"
8 }
9}

You 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.

1{
2 "name": "group_1",
3 "childGroups": [
4 "child_group_1"
5 ],
6 "devices": [
7 "csr", "new_device"
8 ],
9 "variables": {}
10}

Via GUI

When viewing a device, you can click the Edit button at the bottom of the page to edit the associated variables of the device.

Update device

When viewing a device group, you can click the + button near the Devices tab at the top to edit the devices associated with that group. You can also select the Group Variables tab and click Edit at the bottom to edit the associated variables of the group.

Update device group

Remove devices

Via API

You 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.

Delete device

When viewing a device group, hover over the vertical ellipsis () at the top and select Delete group from the menu that appears. Confirm the deletion.

Delete device group