lso.playbook

Module that gathers common API responses and data models.

lso.playbook._run_playbook_proc(job_id, playbook_path, extra_vars, inventory, callback)

Run a playbook, internal function.

Parameters:
  • job_id (str) – Identifier of the job that’s executed.

  • playbook_path (str) – Ansible playbook to be executed.

  • extra_vars (dict) – Extra variables passed to the Ansible playbook.

  • callback (str) – Callback URL to return output to when execution is completed.

  • inventory (dict[str, Any] | str) – Ansible inventory to run the playbook against.

lso.playbook.get_playbook_path(playbook_name)

Get the path of a playbook on the local filesystem.

lso.playbook.playbook_launch_error(reason, status_code=400)

Return a PlaybookLaunchResponse for the erroneous start of a playbook execution.

Parameters:
  • reason (str) – The reason why a request has failed.

  • status_code (status) – The HTTP status code that should be associated with this request. Defaults to HTTP 400: Bad request.

Return JSONResponse:

A playbook launch response that’s unsuccessful.

lso.playbook.playbook_launch_success(job_id)

Return a PlaybookLaunchResponse for the successful start of a playbook execution.

Return JSONResponse:

A playbook launch response that’s successful.

lso.playbook.run_playbook(playbook_path, extra_vars, inventory, callback)

Run an Ansible playbook against a specified inventory.

Parameters:
  • playbook_path (Path) – playbook to be executed.

  • extra_vars (dict[str, Any]) – Any extra vars needed for the playbook to run.

  • inventory (dict[str, Any] | str) – The inventory that the playbook is executed against.

  • callback (HttpUrl) – Callback URL where the playbook should send a status update when execution is completed. This is used for workflow-orchestrator to continue with the next step in a workflow.

Returns:

Result of playbook launch, this could either be successful or unsuccessful.

Return type:

fastapi.responses.JSONResponse