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 option

  • extra_vars – dictionary of variables for highest precedence level, analogue to Ansible’s -e option

  • env_vars – Environment variables to be used when running Ansible.

  • verbosity – None for default verbosity or 1-5, equivalent to Ansible’s -v options

  • limit – Matches Ansible’s --limit parameter to further constrain the inventory to be used

  • ident – 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

data_dir: str
env_vars: dict[str, t.Any]
extra_vars: dict[str, t.Any]
forks: int | None = None
host_pattern: str | None = None
ident: str | None = None
inventory: str | list[str] | None = None
limit: str | None = None
metrics_output_path: str | None = None
module: str | None = None
module_args: str | None = None
playbook: str
role: str | None = None
roles_path: str | list[str] | None = None
timeout: int | None = None
verbosity: int | None = None
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)

name: str
raw_event_data: dict[str, 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

Subpackages