Create an Ad Hoc Command
post
/api/v2/ad_hoc_commands/
Make a POST request to this resource with the following ad hoc command fields to create a new ad hoc command:
job_type: (choice)run: Run (default)check: Check
inventory: (id, default=``)limit: (string, default="")credential: (id, default=``)module_name: (choice)command(default)shellyumaptapt_keyapt_repositoryapt_rpmservicegroupusermountpingselinuxsetupwin_pingwin_servicewin_updateswin_groupwin_user
module_args: (string, default="")forks: (integer, default=0)verbosity: (choice)0: 0 (Normal) (default)1: 1 (Verbose)2: 2 (More Verbose)3: 3 (Debug)4: 4 (Connection Debug)5: 5 (WinRM Debug)
extra_vars: (string, default="")become_enabled: (boolean, default=False)diff_mode: (boolean, default=False)
Request
Supported Media Types
- application/json
Root Schema : schema
Example:
{
"credential":1,
"inventory":3,
"module_args":"uptime",
"module_name":"command"
}Response
Supported Media Types
- application/json
201 Response
Example Response (application/json)
{
"become_enabled":false,
"canceled_on":null,
"controller_node":"",
"created":"2018-02-01T08:00:00.000000Z",
"credential":1,
"diff_mode":false,
"elapsed":0,
"execution_node":"",
"extra_vars":"",
"failed":false,
"finished":null,
"forks":0,
"id":2,
"inventory":3,
"job_explanation":"",
"job_type":"run",
"launch_type":"manual",
"limit":"",
"modified":"2018-02-01T08:00:00.000000Z",
"module_args":"uptime",
"module_name":"command",
"name":"command",
"related":{
"activity_stream":"/api/v2/ad_hoc_commands/2/activity_stream/",
"cancel":"/api/v2/ad_hoc_commands/2/cancel/",
"credential":"/api/v2/credentials/1/",
"events":"/api/v2/ad_hoc_commands/2/events/",
"inventory":"/api/v2/inventories/3/",
"notifications":"/api/v2/ad_hoc_commands/2/notifications/",
"relaunch":"/api/v2/ad_hoc_commands/2/relaunch/",
"stdout":"/api/v2/ad_hoc_commands/2/stdout/"
},
"started":null,
"status":"new",
"summary_fields":{
"credential":{
"cloud":false,
"credential_type_id":1,
"description":"",
"id":1,
"kind":"ssh",
"kubernetes":false,
"name":"machine-cred"
},
"inventory":{
"description":"",
"has_active_failures":false,
"has_inventory_sources":false,
"hosts_with_active_failures":0,
"id":3,
"inventory_sources_with_failures":0,
"kind":"",
"name":"inv2",
"organization_id":1,
"total_groups":0,
"total_hosts":0,
"total_inventory_sources":0
},
"user_capabilities":{
"delete":true,
"start":true
}
},
"type":"ad_hoc_command",
"url":"/api/v2/ad_hoc_commands/2/",
"verbosity":0
}
400 Response
Example Response (application/json)
{
"forks":[
"Ensure this value is greater than or equal to 0."
]
}
403 Response
Example Response (application/json)
{
"detail":"You do not have permission to perform this action."
}