Documentation

19. Ad Hoc Command List API Endpoint

Make a GET request to this resource to retrieve the list of ad hoc commands.

GET /api/v1/ad_hoc_commands/
HTTP 200 OK
Content-Type: application/json
Vary: Accept
Allow: GET, POST, HEAD, OPTIONS
X-API-Time: 0.053s

The resulting data structure contains:

{
    "count": 99,
    "next": null,
    "previous": null,
    "results": [
        ...
    ]
}

The count field indicates the total number of ad hoc commands found for the given query. The next and previous fields provides links to additional results if there are more than will fit on a single page. The results list contains zero or more ad hoc command records.

19.1. Results

Each ad hoc command data structure includes the following fields:

  • id: Database ID for this ad hoc command. (integer)
  • type: Data type for this ad hoc command. (multiple choice)
    -ad_hoc_command: Command
  • url: URL for this ad hoc command. (string)
  • related: Data structure with URLs of related resources. (object)
  • summary_fields: Data structure with name/description for related resources. (object)
  • created: Timestamp when this ad hoc command was created. (datetime)
  • modified: Timestamp when this ad hoc command was last modified. (datetime)
  • name: (string)
  • launch_type: (multiple choice)
    • manual: Manual
    • callback: Callback
    • scheduled: Scheduled
    • dependency: Dependency
  • status: (multiple choice)
    • new: New
    • pending: Pending
    • waiting: Waiting
    • running: Running
    • successful: Successful
    • failed: Failed
    • error: Error
    • canceled: Canceled
  • failed: (boolean)
  • started: (datetime)
  • finished: (datetime)
  • elapsed: (decimal)
  • job_explanation: (string)
  • job_type: (multiple choice)
    • run: Run
    • check: Check
    • scan: Scan
  • inventory: (field)
  • limit: (string)
  • credential: (field)
  • module_name: (multiple choice)
    • command
    • shell
    • yum
    • apt
    • apt_key
    • apt_repository
    • apt_rpm
    • service
    • group
    • user
    • mount
    • ping
    • selinux
    • setup
    • win_ping
    • win_service
    • win_updates
    • win_group
    • win_user
  • module_args: (string)
  • forks: (integer)
  • verbosity: (multiple choice)
    • 0: 0 (Normal)
    • 1: 1 (Verbose)
    • 2: 2 (More Verbose)
    • 3: 3 (Debug)
    • 4: 4 (Connection Debug)
    • 5: 5 (WinRM Debug)
  • become_enabled: (boolean)

19.2. Create 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: (multiple choice, required)
    • run: Run (default)
    • check: Check
    • scan: Scan
  • inventory: (field, default=None)
  • limit: (string, default=””)
  • credential: (field, default=None)
  • module_name: (multiple choice)
    • command (default)
    • shell
    • yum
    • apt
    • apt_key
    • apt_repository
    • apt_rpm
    • service
    • group
    • user
    • mount
    • ping
    • selinux
    • setup
    • win_ping
    • win_service
    • win_updates
    • win_group
    • win_user
  • module_args: (string, default=””)
  • forks: (integer, default=0)
  • verbosity: (multiple choice)
    • 0: 0 (Normal) (default)
    • 1: 1 (Verbose)
    • 2: 2 (More Verbose)
    • 3: 3 (Debug)
    • 4: 4 (Connection Debug)
    • 5: 5 (WinRM Debug)
  • become_enabled: (boolean, default=False)

(Ad hoc commands were added in Ansible Tower version 2.2.0).

19.3. Reviewing the Options Endpoint

The Options Endpoint table offers a view of the Options for this endpoint. When viewing the endpoint in the browsable API, clicking the “Options” button gives you the raw JSON for the following:

name Ad Hoc Command List
description # List Ad Hoc Commands: Make a GET request to this resource to retrieve the list of ad hoc commands.
renders
0 application/json
1 text/html
parses
0 application/json
added_in_version 2.2.0
actions
POST
job_type
type multiple choice
required
true
label job type
default run
choices
0
0 run
1 Run
1
0 check
1 Check
2
0 scan
1 Scan
inventory
type field
required
false
default null
limit
type string
required
false
label limit
max_length 1024
default (Empty Text)
credential
type field
required
false
default null
module_name
type multiple choice
required
false
label module name
default command
choices
0
0 command
1 command
1
0 shell
1 shell
2
0 yum
1 yum
3
0 apt
1 apt
4
0 apt_key
1 apt_key
5
0 apt_repository
1 apt_repository
6
0 apt_rpm
1 apt_rpm
7
0 service
1 service
8
0 group
1 group
9
0 user
1 user
10
0 mount
1 mount
11
0 ping
1 ping
12
0 selinux
1 selinux
13
0 setup
1 setup
14
0 win_ping
1 win_ping
15
0 win_service
1 win_service
16
0 win_updates
1 win_updates
17
0 win_group
1 win_group
18
0 win_user
1 win_user
module_args
type string
required
false
label module args
default (Empty Text)
forks
type integer
required
false
label forks
default 0
verbosity
type multiple choice
required
false
label verbosity
default 0
choices
0
0 0
1 0 (Normal)
1
0 1
1 1 (Verbose)
2
0 2
1 2 (More Verbose)
3
0 3
1 3 (Debug)
4
0 4
1 4 (Connection Debug)
5
0 5
1 5 (WinRM Debug)
become_enabled
type boolean
required
false
label become enabled
default
false
GET
id
type integer
label ID
help_text Database ID for this ad hoc command.
type
type multiple choice
help_text Data type for this ad hoc command.
choices
0
0 ad_hoc_command
1 Command
url
type string
help_text URL for this ad hoc command.
related
type object
help_text Data structure with URLs of related resources.
summary_fields
type object
help_text Data structure with name/description for related resources.
created
type datetime
help_text Timestamp when this ad hoc command was created.
modified
type datetime
help_text Timestamp when this ad hoc command was last modified.
name
type string
launch_type
type multiple choice
label launch type
choices
0
0 manual
1 Manual
1
0 callback
1 Callback
2
0 scheduled
1 Scheduled
3
0 dependency
1 Dependency
status
type multiple choice
label status
choices
0
0 new
1 New
1
0 pending
1 Pending
2
0 waiting
1 Waiting
3
0 running
1 Running
4
0 successful
1 Successful
5
0 failed
1 Failed
6
0 error
1 Error
7
0 canceled
1 Canceled
failed
type boolean
label failed
started
type datetime
label started
finished
type datetime
label finished
elapsed
type decimal
label elapsed
job_explanation
type string
label job explanation
job_type
type multiple choice
label job type
choices
0
0 run
1 Run
1
0 check
1 Check
2
0 scan
1 Scan
inventory
type field
limit
type string
label limit
credential
type field
module_name
type multiple choice
label module name
choices
0
0 command
1 command
1
0 shell
1 shell
2
0 yum
1 yum
3
0 apt
1 apt
4
0 apt_key
1 apt_key
5
0 apt_repository
1 apt_repository
6
0 apt_rpm
1 apt_rpm
7
0 service
1 service
8
0 group
1 group
9
0 user
1 user
10
0 mount
1 mount
11
0 ping
1 ping
12
0 selinux
1 selinux
13
0 setup
1 setup
14
0 win_ping
1 win_ping
15
0 win_service
1 win_service
16
0 win_updates
1 win_updates
17
0 win_group
1 win_group
18
0 win_user
1 win_user
module_args
type string
label module args
forks
type integer
label forks
verbosity
type multiple choice
label verbosity
choices
0
0 0
1 0 (Normal)
1
0 1
1 1 (Verbose)
2
0 2
1 2 (More Verbose)
3
0 3
1 3 (Debug)
4
0 4
1 4 (Connection Debug)
5
0 5
1 5 (WinRM Debug)
become_enabled
type boolean
label become enabled
types
0 ad_hoc_command
search_fields
0 description
1 name