theforeman.foreman.job_invocation module – Invoke Remote Execution Jobs
Note
This module is part of the theforeman.foreman collection (version 5.11.0).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install theforeman.foreman. You need further requirements to be able to use this module, see Requirements for details.
To use it in a playbook, specify: theforeman.foreman.job_invocation.
New in theforeman.foreman 1.4.0
Synopsis
- Invoke and schedule Remote Execution Jobs
Requirements
The below requirements are needed on the host that executes this module.
- requests
Parameters
Parameter | Comments |
|---|---|
bookmark string | Bookmark to infer the search query from |
ca_path path | PEM formatted file that contains a CA certificate to be used for validation. If the value is not specified in the task, the value of environment variable |
command string | Command to be executed on host. Required for command templates |
concurrency_control dictionary | Control concurrency level and distribution over time |
|
concurrency_level integer |
Maximum jobs to be executed at once |
|
time_span integer |
Distribute tasks over given number of seconds This is removed since foreman_remote_execution-11.0.0 |
description_format string | Override the description format from the template for this invocation only |
execution_timeout_interval integer | Override the timeout interval from the template for this invocation only |
feature string added in theforeman.foreman 5.8.0 | Feature label that should be triggered A job template assigned to this feature will be used |
inputs dictionary | Inputs to use |
job_template string | Job template to execute |
oauth1_consumer_key string | OAuth1 consumer key for accessing the Foreman server. If the value is not specified in the task, the value of environment variable |
oauth1_consumer_secret string | OAuth1 consumer secret for accessing the Foreman server. If the value is not specified in the task, the value of environment variable |
password string | Password of the user accessing the Foreman server. If the value is not specified in the task, the value of environment variable |
randomized_ordering boolean | Whether to order the selected hosts randomly Choices:
|
recurrence dictionary | Schedule a recurring job |
|
cron_line string |
How often the job should occur, in the cron format |
|
end_time string |
Perform no more executions after this time |
|
max_iteration integer |
Repeat a maximum of N times |
|
purpose string |
Designation of a special purpose |
scheduling dictionary | Schedule the job to start at a later time |
|
start_at string |
Schedule the job for a future time |
|
start_before string |
Indicates that the action should be cancelled if it cannot be started before this time. |
search_query string | Search query to identify hosts |
server_url string / required | URL of the Foreman server. If the value is not specified in the task, the value of environment variable |
ssh dictionary | ssh related options |
|
effective_user string |
What user should be used to run the script (using sudo-like mechanisms) Defaults to a template parameter or global setting |
targeting_type string | Dynamic query updates the search results before execution (useful for scheduled jobs) Choices:
|
use_gssapi boolean | Use GSSAPI to perform the authentication, typically this is for Kerberos or Kerberos through Negotiate authentication. Requires the Python library requests-gssapi to be installed. If the value is not specified in the task, the value of environment variable Choices:
|
username string | Username accessing the Foreman server. If the value is not specified in the task, the value of environment variable |
validate_certs boolean | Whether or not to verify the TLS certificates of the Foreman server. If the value is not specified in the task, the value of environment variable Choices:
|
Attributes
Attribute | Support | Description |
|---|---|---|
check_mode | Support: full | Can run in check_mode and return changed status prediction without modifying the entity |
diff_mode | Support: full | Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode |
Examples
- name: "Run remote command on a single host once"
theforeman.foreman.job_invocation:
search_query: "name ^ (foreman.example.com)"
command: 'ls'
job_template: "Run Command - SSH Default"
ssh:
effective_user: "tester"
- name: "Run ansible command on active hosts once a day"
theforeman.foreman.job_invocation:
bookmark: 'active'
command: 'pwd'
job_template: "Run Command - Ansible Default"
recurrence:
cron_line: "30 2 * * *"
concurrency_control:
concurrency_level: 2
- name: "Run the katello_package_install feature to install a package on a single host"
theforeman.foreman.job_invocation:
search_query: "name ^ (foreman.example.com)"
feature: 'katello_package_install'
inputs: 'package=podman'
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
|---|---|
entity dictionary | Final state of the affected entities grouped by their type. Returned: success |
|
job_invocations list / elements=dictionary |
List of job invocations Returned: success |
Collection links
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/projects/ansible/latest/collections/theforeman/foreman/job_invocation_module.html