ansible_sdk package
- class ansible_sdk.AnsibleJobDef(*args, **kwargs)
Bases:
_DataclassReplaceMixin
Common Ansible job definition values
- Parameters:
data_dir – path to a directory structure containing the Ansible project content and inventory.
playbook – relative path or FQCN of a playbook to run under
data_dir
inventory – relative path to inventory file(s) or directory under
data_dir
, analogue to Ansible’s-i
optionextra_vars – dictionary of variables for highest precedence level, analogue to Ansible’s
-e
optionenv_vars – Environment variables to be used when running Ansible.
verbosity – None for default verbosity or 1-5, equivalent to Ansible’s
-v
optionslimit – Matches Ansible’s
--limit
parameter to further constrain the inventory to be usedident – The run identifier for this invocation of Runner. Will be used to create and name the artifact directory holding the results of the invocation.
forks – Control Ansible parallel concurrency
module – The module that will be invoked in ad-hoc mode by runner when executing Ansible.
module_args – The module arguments that will be supplied to ad-hoc mode.
host_pattern – The host pattern to match when running in ad-hoc mode.
timeout – The timeout value in seconds that will be passed to
subprocess
invocation while executing command. It the timeout is triggered it will force cancel the execution.role – Name of the role to execute.
roles_path – Directory or list of directories to assign to ANSIBLE_ROLES_PATH
metrics_output_path – A path to directory to collect metrics
- class ansible_sdk.AnsibleJobEvent(name: str, raw_event_data: dict[str, Any])
Bases:
Mapping
Container object for various Ansible events.
- Parameters:
name – name of the event type
raw_event_data – dictionary of the raw event data
stdout – display text output associated with this event (if any)
- class ansible_sdk.AnsibleJobStatus(job_def: AnsibleJobDef)
Bases:
object
Status object for monitoring running/completed jobs.
- cancel()
Request cancellation of a running job by the executor. On successful cancellation,
CancelledError
will be on raised on running iterators and on any awaiters of this job object.
- drop_event(evt: AnsibleJobEvent)
Request discard of event data that is no longer needed.
- Parameters:
evt – The returned event object to be discarded
- property events: AsyncIterator[AnsibleJobEvent]
Async iterator to enumerate events from this job. Events are yielded live while the job is running; the iterator will not complete until the job has completed or failed. In cases of job failure or cancellation, the iterator will raise an exception with the appropriate detail.
- Returns:
a live iterator of
AnsibleJobEvent
data for this job
- property stdout_lines: AsyncIterator[str]
Async iterator to enumerate lines of display output text from this job. Text lines are yielded live while the job is running; the iterator will not complete until the job has completed or failed. In cases of job failure or cancellation, the iterator will raise an exception with the appropriate detail.
- Returns:
an iterator of lines of display output text from the Ansible job