W3cubDocs

/Ansible

community.general.rundeck_job_run – Run a Rundeck job

Note

This plugin is part of the community.general collection (version 3.8.1).

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 community.general.

To use it in a playbook, specify: community.general.rundeck_job_run.

New in version 3.8.0: of community.general

Synopsis

  • This module runs a Rundeck job specified by ID.

Parameters

Parameter Choices/Defaults Comments
abort_on_timeout
boolean
    Choices:
  • no
  • yes
Send a job abort request if exceeded the wait_execution_timeout specified.
api_token
string / required
Rundeck User API Token.
api_version
integer
Default:
39
Rundeck API version to be used.
API version must be at least 14.
client_cert
path
PEM formatted certificate chain file to be used for SSL client authentication.
This file can also include the key as well, and if the key is included, client_key is not required.
client_key
path
PEM formatted file that contains your private key to be used for SSL client authentication.
If client_cert contains both the certificate and key, this option is not required.
filter_nodes
string
Filter the nodes where the jobs must run.
force
boolean
    Choices:
  • no
  • yes
If yes do not get a cached copy.
Alias thirsty has been deprecated and will be removed in 2.13.

aliases: thirsty
force_basic_auth
boolean
    Choices:
  • no
  • yes
Credentials specified with url_username and url_password should be passed in HTTP Header.
http_agent
string
Default:
"ansible-httpget"
Header to identify as, generally appears in web server logs.
job_id
string / required
The job unique ID.
job_options
dictionary
The job options for the steps.
Numeric values must be quoted.
loglevel
string
    Choices:
  • debug
  • verbose
  • info
  • warn
  • error
Log level configuration.
run_at_time
string
Schedule the job execution to run at specific date and time.
ISO-8601 date and time format like 2021-10-05T15:45:00-03:00.
url
string / required
Rundeck instance URL.
url_password
string
The password for use in HTTP basic authentication.
If the url_username parameter is not specified, the url_password parameter will not be used.
url_username
string
The username for use in HTTP basic authentication.
This parameter can be used without url_password for sites that allow empty passwords
use_gssapi
boolean
added in 2.11 of ansible.builtin
    Choices:
  • no
  • yes
Use GSSAPI to perform the authentication, typically this is for Kerberos or Kerberos through Negotiate authentication.
Requires the Python library gssapi to be installed.
Credentials for GSSAPI can be specified with url_username/url_password or with the GSSAPI env var KRB5CCNAME that specified a custom Kerberos credential cache.
NTLM authentication is not supported even if the GSSAPI mech for NTLM has been installed.
use_proxy
boolean
    Choices:
  • no
  • yes
If no, it will not use a proxy, even if one is defined in an environment variable on the target hosts.
validate_certs
boolean
    Choices:
  • no
  • yes
If no, SSL certificates will not be validated.
This should only be used on personally controlled sites using self-signed certificates.
wait_execution
boolean
    Choices:
  • no
  • yes
Wait until the job finished the execution.
wait_execution_delay
integer
Default:
5
Delay, in seconds, between job execution status check requests.
wait_execution_timeout
integer
Default:
120
Job execution wait timeout in seconds.
If the timeout is reached, the job will be aborted.
Keep in mind that there is a sleep based on wait_execution_delay after each job status check.

Examples

- name: Run a Rundeck job
  community.general.rundeck_job_run:
    url: "https://rundeck.example.org"
    api_version: 39
    api_token: "mytoken"
    job_id: "xxxxxxxxxxxxxxxxx"
  register: rundeck_job_run

- name: Show execution info
  ansible.builtin.debug:
    var: rundeck_job_run.execution_info

- name: Run a Rundeck job with options
  community.general.rundeck_job_run:
    url: "https://rundeck.example.org"
    api_version: 39
    api_token: "mytoken"
    job_id: "xxxxxxxxxxxxxxxxx"
    job_options:
        option_1: "value_1"
        option_2: "value_3"
        option_3: "value_3"
  register: rundeck_job_run

- name: Run a Rundeck job with timeout, delay between status check and abort on timeout
  community.general.rundeck_job_run:
    url: "https://rundeck.example.org"
    api_version: 39
    api_token: "mytoken"
    job_id: "xxxxxxxxxxxxxxxxx"
    wait_execution_timeout: 30
    wait_execution_delay: 10
    abort_on_timeout: true
  register: rundeck_job_run

- name: Schedule a Rundeck job
  community.general.rundeck_job_run:
    url: "https://rundeck.example.org"
    api_version: 39
    api_token: "mytoken"
    job_id: "xxxxxxxxxxxxxxxxx"
    run_at_time: "2021-10-05T15:45:00-03:00"
  register: rundeck_job_schedule

- name: Fire-and-forget a Rundeck job
  community.general.rundeck_job_run:
    url: "https://rundeck.example.org"
    api_version: 39
    api_token: "mytoken"
    job_id: "xxxxxxxxxxxxxxxxx"
    wait_execution: false
  register: rundeck_job_run

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
execution_info
dictionary
always
Rundeck job execution metadata.

Sample:
{'execution_info': {'argstring': '-exit_code 0', 'date-ended': {'date': '2021-10-05T15:50:26Z', 'unixtime': 1633449026358}, 'date-started': {'date': '2021-10-05T15:50:20Z', 'unixtime': 1633449020784}, 'description': "sleep 5 && echo 'Test!' && exit ${option.exit_code}", 'executionType': 'user', 'href': 'https://rundeck.example.org/api/39/execution/1', 'id': 1, 'job': {'averageDuration': 4917, 'description': '', 'group': '', 'href': 'https://rundeck.example.org/api/39/job/697af0c4-72d3-4c15-86a3-b5bfe3c6cb6a', 'id': '697af0c4-72d3-4c15-86a3-b5bfe3c6cb6a', 'name': 'Test', 'options': {'exit_code': '0'}, 'permalink': 'https://rundeck.example.org/project/myproject/job/show/697af0c4-72d3-4c15-86a3-b5bfe3c6cb6a', 'project': 'myproject'}, 'output': 'Test!', 'permalink': 'https://rundeck.example.org/project/myproject/execution/show/1', 'project': 'myproject', 'serverUUID': '5b9a1438-fa3a-457e-b254-8f3d70338068', 'status': 'succeeded', 'successfulNodes': ['localhost'], 'user': 'admin'}, 'msg': 'Job execution succeeded!'}


Authors

  • Phillipe Smith (@phsmith)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/rundeck_job_run_module.html