lso.routes.playbook

The API endpoint from which Ansible playbooks can be executed.

class lso.routes.playbook.PlaybookRunParams(*, playbook_name, callback, inventory, extra_vars={})

Bases: BaseModel

Parameters for executing an Ansible playbook.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

callback

The address where LSO should call back to upon completion.

extra_vars

Extra variables that should get passed to the playbook. This includes any required configuration objects from the workflow orchestrator, commit comments, whether this execution should be a dry run, a trouble ticket number, etc. Which extra vars are required solely depends on what inputs the playbook requires.

inventory

The inventory to run the playbook against. This inventory can also include any host vars, if needed. When including host vars, it should be a dictionary. Can be a simple string containing hostnames when no host vars are needed. In the latter case, multiple hosts should be separated with a \n newline character only.

model_computed_fields = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields = {'callback': FieldInfo(annotation=Url, required=True, metadata=[UrlConstraints(max_length=2083, allowed_schemes=['http', 'https'], host_required=None, default_host=None, default_port=None, default_path=None)]), 'extra_vars': FieldInfo(annotation=dict[str, Any], required=False, default={}), 'inventory': FieldInfo(annotation=Union[dict[str, Any], str], required=True, metadata=[AfterValidator(func=<function _inventory_validator>)]), 'playbook_name': FieldInfo(annotation=Path, required=True, metadata=[AfterValidator(func=<function _playbook_path_validator>)])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

playbook_name

The filename of a playbook that’s executed. It should be present inside the directory defined in the configuration option ANSIBLE_PLAYBOOKS_ROOT_DIR.

class lso.routes.playbook.PlaybookRunResponse(*, job_id)

Bases: BaseModel

PlaybookRunResponse domain model schema.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_computed_fields = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields = {'job_id': FieldInfo(annotation=UUID, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

lso.routes.playbook.run_playbook_endpoint(params)

Launch an Ansible playbook to modify or deploy a subscription instance.

The response will contain either a job ID, or error information.

Parameters:

params (PlaybookRunParams) – Parameters for executing a playbook.

Return JSONResponse:

Response from the Ansible runner, including a run ID.