Automation Gateway clients execute roles on a device using the REST /roles/{role_name}/execute
route. The role execution input parameter is a JSON object that contains an array of host strings and an args
object that includes a set of key/value pairs that are specific to the role itself. A JSON schema that describes each role's argument parameters is available via the /roles/{role_name}
route. Detailed documentation on role endpoints can be found in the API Documentation section of the Automation Gateway UI.
Role Request Object
Below is a sample role input parameter for the itential_set_config
role:
{
"hosts":["eos_host"],
"args":
{
"transactions": [
{
"action": "add",
"parents": ["interface Management 1"],
"config_line": "ip address 10.1.2.3/24",
"id": "anyIDString"
}
]
},
"strict_args": true
}
An Ansible role consists of a number of tasks, each of which produces its own results object, as discussed in the section that follows.
Automation Gateway collects the task results objects and returns them as an array in the order in which they were executed.
For information on execution flow in the release versions of IAG, see: Execution Flow by Role Type
Task Results Object & Key
The Itential Ansible roles include a task results object with a task key whose value always takes the form of the "Task key naming convention" shown below:
{role} response
Where {role}
is replaced with the name of the role executed.
Example: itential_set_config response
The results
object from that response
task contains the response data from the role for the device.
All other task results can be ignored and are available for informational and debugging purposes only.
Note that the format of the data contained within the results object will vary per role.
In addition, a status key indicates whether the task succeeded (SUCCESS
), or failed (FAILURE
).
Roles that contain multiple requests will have multiple response
objects, each with their own status and results keys.
Role Response
Below is the sample role response for the itential_set_config
role:
[
{
"role": "itential_set_config",
"task": "execute config module on eos platform",
"host": "eos_host",
"status": "SUCCESS",
"argument_warnings": null,
"results": {
"commands": [
"interface Management 1",
"ip address 10.0.5.17/24"
],
"changed": true,
"session": "ansible_1548718829",
"updates": [
"interface Management 1",
"ip address 10.0.5.17/24"
],
"diff": {
"prepared": "--- system:/running-config\n+++ session:/ansible_1548718829-session-config\n@@ -27,6 +27,7 @@\n
ip address 192.168.32.20/24\n !\n interface Management1\n+ ip address 10.0.5.17/24\n !\n ip route 0.0.0.0/0 10.0.2.2\n !"
}
}
},
{
"role": "itential_set_config",
"task": "itential_set_config response",
"host": "eos_host",
"status": "SUCCESS",
"argument_warnings": null,
"results": {
"config_request": {
"action": "add",
"config_line": "ip address 10.0.5.17/24",
"parents": [
"interface Management 1"
],
"id": "anyIDString"
},
"config_response": {
"failed": false,
"changed": true,
"id": "anyIDString"
},
"changed": false
}
}
]