EXAMPLE-tower-job-poll¶
EXAMPLE: AWX / Tower job via polling
Warning
THIS IS AN EXAMPLE - you must modify values to fit your local environment appropriately. Replace the bearer token, review the extra_vars payload, and confirm the URLs match your AWX / Tower deployment before applying to a real machine.
Launches an AWX / Tower job template and polls for completion using
the exponential-backoff strategy. The example values target a generic
tower.example.com host and job template id 399 with a sample
network-fabric extra_vars payload; replace these for your site.
What this profile does¶
- POSTs to
/api/v2/job_templates/399/launch/with the configuredextra_varspayload (datacenter, action, servers list). - Captures the job ID from the launch response (top-level
idfield). - Records
id,url, andstatusfrom the launch response asinventory/tower/*adhoc Params on the Machine for audit. - Polls
/api/v2/jobs/<id>/with exponential backoff:- Initial sleep: 10 seconds
- Doubled each iteration: 10, 20, 40, 60, 60, ...
- Capped at: 60 seconds (max-interval)
- Total max wait: 900 seconds (15 minutes)
- Treats the top-level
statusfield of each poll response as:successful-> terminal success (exit 0, clear state)pending/waiting/running-> continue waitingfailed/error/canceled-> terminal failure (exit 1, state=failure)- anything else -> terminal failure with "unexpected status"
The wait and failure slots are configured as arrays so the full
AWX state machine (multiple non-terminal and multiple terminal-failure
states) is handled cleanly. The first poll can land on pending or
waiting without misclassification.
TLS verification¶
This profile leaves tower/skip-tls-verify at the default true,
bypassing certificate validation. Set to false if the DRP endpoint
trusts the certificate chain for your AWX / Tower host.
Required operator input¶
Before applying, replace the placeholder value of tower/bearer-token
with a real AWX OAuth2 bearer token that has permission to launch
job template 399. The placeholder is intentionally invalid so a
forgotten replacement fails fast with a 401 at POST time.
Recovery after a non-success terminal¶
If polling times out (max-time-expired) or fails (failure), the
machine retains tower/job-poll-state and tower/job-id. See the
Operator Recovery section of the tower-invoke-curl task for the
two recovery workflows (resume on existing job ID, or start fresh).
Objects that Reference EXAMPLE-tower-job-poll¶
Not used in current content packs
Objects used by EXAMPLE-tower-job-poll¶
- params tower/job-wait-type in field Params as value exponential
- params tower/variables in field Params as value map[credential_passwords:map[] extra_vars:map[action:DEFINE datacenter:NYZ servers:[map[cabinet:NYZ3-2130 leafs_interface:Ethernet12/1 port_profile:D-DEV rack_unit:12 server_name:nyzls3653d server_speed:100g-4]]]]
- params tower/job-poll-id-field in field Params as value id
- params tower/job-poll-interval in field Params as value 10
- params tower/job-poll-status-map in field Params as value map[failure:[failed error canceled] field:status success:[successful] wait:[pending waiting running]]
- params tower/output-to-inventory in field Params as value [id url status]
- params tower/skip-tls-verify in field Params as value true
- params tower/url in field Params as value https://tower.example.com/api/v2/job_templates/399/launch/
- params tower/bearer-token in field Params as value REPLACE_ME_WITH_REAL_AWX_OAUTH_TOKEN
- params tower/content-type in field Params as value application/json
- params tower/job-poll-max-interval in field Params as value 60
- params tower/job-poll-max-wait in field Params as value 900
- params tower/job-poll-url in field Params as value https://tower.example.com/api/v2/jobs/JOB_ID/