towerlib package¶
Subpackages¶
- towerlib.entities package
- Submodules
- towerlib.entities.core module
- towerlib.entities.credential module
- towerlib.entities.group module
- towerlib.entities.host module
- towerlib.entities.instance module
- towerlib.entities.inventory module
- towerlib.entities.inventory_script module
- towerlib.entities.inventory_source module
- towerlib.entities.job module
- towerlib.entities.notification module
- towerlib.entities.organization module
- towerlib.entities.project module
- towerlib.entities.role module
- towerlib.entities.schedule module
- towerlib.entities.settings module
- towerlib.entities.team module
- towerlib.entities.user module
- Module contents
Submodules¶
towerlib.towerlib module¶
Main code for towerlib.
-
class
towerlib.towerlib.
Tower
(host, username, password, secure=False, ssl_verify=True, token=None, pool_connections=10, pool_maxsize=25, timeout=5)[source]¶ Bases:
object
Models the api of ansible tower.
-
associate_groups_with_inventory_host
(organization, inventory, hostname, groups)[source]¶ Adds groups to a host.
Parameters: - organization – The name of the organization the inventory belongs to.
- inventory – The inventory to retrieve the host from.
- hostname – The name of the host to add the groups to.
- groups – A string of a single group or a list or tuple of group names to add to host.
Returns: True on complete success, False otherwise.
Return type: bool
Raises: InvalidHost
– The host provided as argument does not exist.
-
cluster
¶ The cluster status of tower.
Returns: The information about the state of the cluster. Return type: Cluster
-
configuration
¶ The configuration of the tower instance.
Returns: The configuration of the tower instance. Return type: Config
-
create_credential_in_organization
(organization, name, description, credential_type, user=None, team=None, inputs_='{}')[source]¶ Creates a credential under an organization.
Parameters: - organization – The name of the organization to create a credential under.
- name – The name of the credential to create.
- description – The description of the credential to create.
- user – The username of the user to assign to the credential.
- team – The name of the team to assign to the credential.
- credential_type – The name of the type of the credential.
- inputs – A json with the values to set to the credential according to what is required by its type.
Returns: The created credential upon success, None otherwise.
Return type: Raises: InvalidOrganization
– The organization provided as argument does not exist.InvalidCredentialType
– The credential type provided as argument does not exist.InvalidVariables
– The inputs provided as argument is not valid json.InvalidUser
– The user provided as argument does not exist.InvalidTeam
– The team provided as argument does not exist.
-
create_credential_in_organization_with_type_id
(organization, name, description, user, team, credential_type_id, inputs_='{}')[source]¶ Creates a credential under an organization.
Parameters: - organization (str) – The name of the organization to create a credential under.
- name (str) – The name of the credential to create.
- description (str) – The description of the credential to create.
- user (str) – The username of the user to assign to the credential.
- team (str) – The name of the team to assign to the credential.
- credential_type_id (int) – The number of the type of the credential.
- inputs (str) – A json with the values to set to the credential according to what is required by its type.
Returns: The created credential upon success, None otherwise.
Return type: Raises: InvalidOrganization
– The organization provided as argument does not exist.InvalidUser
– The user provided as argument does not exist.InvalidTeam
– The team provided as argument does not exist.InvalidVariables
– The inputs provided as argument is not valid json.
-
create_credential_type
(name, description, type_, inputs_='{}', injectors='{}')[source]¶ Creates a credential type in tower.
Parameters: - name – The name of the credential type.
- description – The description of the credential type.
- type – The kind of credential type.Valid values (u’scm’, u’ssh’, u’vault’, u’net’, u’cloud’, u’insights’).
- inputs (str) – A json of the inputs to set to the credential type.
- injectors (str) – A json of the injectors to set to the credential type.
Returns: CredentialType on success, None otherwise.
Raises: InvalidCredentialTypeKind
– The credential type kind provided as argument does not exist.InvalidVariables
– The inputs or injectors provided as argument is not valid json.
-
create_credential_with_credential_type_id
(name: str, credential_type_id: int, description='', organization_id=None, user_id=None, team_id=None, inputs='{}')[source]¶ Creates a credential using the id of the provided credential type.
Parameters: - name (str) – The name of the credential
- credential_type_id (int) – The number of the credential type
- description (str) – The description of the credential
- organization_id (int) – The id of the organization
- user_id (int) – The id of the user
- team_id (int) – The id of the team
- inputs (str) – The input to provide to the credential as json in a string format
Returns: A credential object on success, false otherwise.
Return type: credential (Credential|None)
-
create_host_in_inventory
(organization, inventory, name, description, variables='{}')[source]¶ Creates a host under an inventory.
Parameters: - organization – The name of the organization the inventory belongs to.
- inventory – The name of the inventory to create the host under.
- name – The name of the host.
- description – The description of the host.
- variables – A json of the variables to be set on the host.
Returns: The created host on success, None otherwise.
Return type: Raises: InvalidInventory
– The inventory provided as argument does not exist.
-
create_inventory_group
(organization, inventory, name, description, variables='{}')[source]¶ Creates a group in an inventory in tower.
Parameters: - organization – The organization the inventory belongs to.
- inventory – The name of the inventory to create the group in.
- name – The name of the group to create.
- description (str) – The description of the group to create.
- variables (str) – The Variables of the group in a json string format.
Returns: True on success, False otherwise.
Return type: bool
Raises: InvalidGroup
– The group provided as argument does not exist.
-
create_job_template
(name, description, organization, inventory, project, playbook, credential=None, credential_type=None, instance_groups=None, host_config_key=None, job_type='run', vault_credential=None, forks=0, limit=0, verbosity=0, extra_vars='', job_tags='', force_handlers=False, skip_tags='', start_at_task='', timeout=0, use_fact_cache=False, ask_diff_mode_on_launch=False, ask_variables_on_launch=False, ask_limit_on_launch=False, ask_tags_on_launch=False, ask_skip_tags_on_launch=False, ask_job_type_on_launch=False, ask_verbosity_on_launch=False, ask_inventory_on_launch=False, ask_credential_on_launch=False, survey_enabled=False, become_enabled=False, diff_mode=False, allow_simultaneous=False)[source]¶ Creates a job template.
Parameters: - name – The name of the job template to create.
- description – The description of the job template to create.
- organization – The organization the inventory belongs to.
- inventory – The inventory to use for the template.
- project – The project to use for the template.
- playbook – The playbook to run for the template.
- credential – The credential to use for the template.
- credential_type – The type of the credential to use for the template.
- instance_groups – The instance groups to associate to the template.
- host_config_key – A host config key.
- job_type – The job type. Valid values are ‘run’ and ‘check’.
- vault_credential – A vault credential.
- forks – The number of parallel or simultaneous processes to use while executing the playbook.
- limit – A host pattern to constrain the list of hosts that will be managed or affected by the playbook.
- verbosity – The level of output ansible will produce as the playbook executes. Values [0-4].
- extra_vars – Pass extra command line variables to the playbook.
- job_tags – Tags to identify the template.
- force_handlers –
- skip_tags – Skip specific parts of a play or task with tags.
- start_at_task –
- timeout –
- use_fact_cache –
- ask_diff_mode_on_launch –
- ask_variables_on_launch –
- ask_limit_on_launch –
- ask_tags_on_launch –
- ask_skip_tags_on_launch –
- ask_job_type_on_launch –
- ask_verbosity_on_launch –
- ask_inventory_on_launch –
- ask_credential_on_launch –
- survey_enabled –
- become_enabled –
- diff_mode –
- allow_simultaneous –
Returns: The created job template if successful, None otherwise.
Return type: Raises: InvalidInventory
– The inventory provided as argument does not exist.InvalidProject
– The project provided as argument does not exist.InvalidPlaybook
– The playbook provided as argument does not exist in project.InvalidInstanceGroup
– The instance group provided as argument does not exist.InvalidJobType
– The job type provided as argument does not exist.InvalidVerbosity
– The verbosity provided is not in valid range of 0-4.InvalidCredentialType
– The credential type is invalid.
-
create_organization
(name, description='')[source]¶ Creates an organization in tower.
Parameters: - name – The name of the organization to create.
- description – The description of the organization to create.
Returns: The organization on success, None otherwise.
Return type:
-
create_organization_inventory
(organization, name, description, variables='{}')[source]¶ Creates an inventory under an organization.
Parameters: - organization – The name of the organization to create the inventory under
- name – The name of the inventory
- description – The description of the inventory
- variables – A json of the variables to be set on the inventory
Returns: The created inventory on success, None otherwise
Return type: Raises: InvalidOrganization
– The organization provided as argument does not exist.
-
create_organization_inventory_script
(organization, name, description, script)[source]¶ Creates a custom inventory script.
Parameters: - organization – The organization the inventory script is part of.
- name – Name of the inventory script.
- description – The description of the inventory script.
- script – The script of the inventory script.
Returns: The created inventory script is successful, None otherwise.
Return type: Inventory_script
-
create_project_in_organization
(organization, name, description, credential, scm_url, local_path='', custom_virtualenv='', scm_branch='master', scm_type='git', scm_clean=True, scm_delete_on_update=False, scm_update_on_launch=True, scm_update_cache_timeout=0)[source]¶ Creates a project in an organization.
Parameters: - organization (str) – The name of the organization to create the project under.
- name (str) – The name of the project.
- description (str) – The description of the project.
- credential (str) – The name of the credential to use for the project.
- scm_url (str) – The url of the scm.
- local_path (str) – Local path (relative to PROJECTS_ROOT) containing playbooks and files for this project.
- custom_virtualenv (str) – Local absolute file path containing a custom Python virtualenv to use.
- scm_branch (str) – The default branch of the scm.
- scm_type (str) – The type of the scm.
- scm_clean (bool) – Clean scm or not.
- scm_delete_on_update (bool) – Delete scm on update.
- scm_update_on_launch (bool) – Update scm on launch.
- scm_update_cache_timeout (int) – Scm cache update.
Returns: The created project on success, None otherwise.
Return type: Raises: InvalidOrganization
– The organization provided as argument does not exist.
-
create_team_in_organization
(organization, team_name, description='')[source]¶ Creates a team under an organization.
Parameters: - organization – The name of the organization to create the team under.
- team_name – The name of the team to create.
- description – The description of the team to create.
Returns: The created team on success, None otherwise.
Return type: Raises: InvalidOrganization
– The organization provided as argument does not exist.
-
create_user
(username, password, first_name='', last_name='', email='', is_superuser=False, is_system_auditor=False)[source]¶ Creates a user in AWX/Tower.
Parameters: - username – The username to create for the user.
- password – The password to set for the user.
- first_name – The first name of the user.
- last_name – The last name of the user.
- email – The email of the user.
- is_superuser – Is the user a super user
- is_system_auditor – Is the user an auditor
Returns: The created User object on success, None otherwise.
Return type:
-
create_user_in_organization
(organization, username, password, first_name, last_name, email)[source]¶ Creates a user in an organization.
Parameters: - organization – The name of the organization to create the user under.
- username – The user’s username.
- password – The user’s password.
- first_name – The user’s first name.
- last_name – The user’s last name.
- email – The user’s email.
Returns: The user on success, None otherwise.
Return type: Raises: InvalidOrganization
– The organization provided as argument does not exist.
-
credential_types
¶ The credential_types configured in tower.
Returns: The manager object for credentials type. Return type: EntityManager
-
credentials
¶ The credentials configured in tower.
Returns: The manager object for credentials. Return type: EntityManager
-
custom_credential_types
¶ The custom credential_types configured in tower.
Returns: The manager object for external credential types. Return type: EntityManager
-
delete_credential_type
(name)[source]¶ Deletes a credential_type from tower.
Parameters: name – The name of the credential_type to delete. Returns: True on success, False otherwise. Return type: bool Raises: InvalidCredential
– The credential provided as argument does not exist.
-
delete_inventory_group
(organization, inventory, name)[source]¶ Deletes a group from tower.
Parameters: - organization – The organization the inventory belongs to.
- inventory – The name of the inventory to retrieve the group from.
- name – The name of the group to delete.
Returns: True on success, False otherwise.
Return type: bool
Raises: InvalidGroup
– The group provided as argument does not exist.
-
delete_inventory_host
(organization, inventory, name)[source]¶ Deletes an host from tower.
Parameters: - organization – The name of the organization the inventory belongs to.
- inventory – The name of the inventory to delete the host from.
- name – The name of the host to delete.
Returns: True on success, False otherwise.
Return type: bool
Raises: InvalidHost
– The host provided as argument does not exist.
-
delete_job_template
(name)[source]¶ Deletes a job template from tower.
Parameters: name – The name of the job template to delete. Returns: True on success, False otherwise. Return type: bool Raises: InvalidJobTemplate
– The job template provided as argument does not exist.
-
delete_organization
(name)[source]¶ Deletes an organization from tower.
Parameters: name – The name of the organization to delete. Returns: True on success, False otherwise. Return type: bool Raises: InvalidOrganization
– The organization provided as argument does not exist.
-
delete_organization_credential_by_name
(organization, name, credential_type)[source]¶ Deletes a credential from an organization.
Parameters: - organization – The organization that owns the credential.
- name – The name of the credential(s) to delete.
- credential_type – The type of the credential.
Returns: True on success, False otherwise.
Return type: bool
Raises: InvalidCredentialType
– The CredentialType given was not found.InvalidOrganization
– The Organization given was not found.InvalidCredential
– The credential was not found.
-
delete_organization_credential_by_name_with_type_id
(organization, name, credential_type_id)[source]¶ Deletes a credential from an organization.
Parameters: - organization (str) – The organization that owns the credential.
- name (str) – The name of the credential(s) to delete.
- credential_type_id (int) – The type of the credential.
Returns: True on success, False otherwise.
Return type: bool
Raises: InvalidOrganization
– The Organization given was not found.InvalidCredential
– The credential was not found.
-
delete_organization_inventory
(organization, name)[source]¶ Deletes an inventory from tower.
Parameters: - organization – The organization the inventory is a member of.
- name – The name of the inventory to delete.
Returns: True on success, False otherwise.
Return type: bool
Raises: InvalidInventory
– The inventory provided as argument does not exist.
-
delete_organization_inventory_script
(organization, name)[source]¶ Deletes an custom inventory script from tower.
Parameters: - organization – The organization the custom inventory script is a member of.
- name – The name of the custom inventory script to delete.
Returns: True on success, False otherwise.
Return type: bool
Raises: InvalidInventory
– The custom inventory script provided as argument does not exist.
-
delete_organization_project
(organization, name)[source]¶ Deletes a project from tower.
Parameters: - organization – The organization the project belongs to.
- name – The name of the project to delete.
Returns: True on success, False otherwise.
Return type: bool
Raises: InvalidProject
– The project provided as argument does not exist.
-
delete_team_in_organization
(organization, name)[source]¶ Deletes a team from tower.
Parameters: - organization – The name of the organization the team belongs to.
- name – The name of the team to delete.
Returns: True on success, False otherwise.
Return type: bool
Raises: InvalidTeam
– The team provided as argument does not exist.
-
delete_user
(username)[source]¶ Deletes a user by username.
Parameters: username – The username of the user to delete. Returns: True on success, False otherwise. Return type: bool Raises: InvalidUser
– The username provided as argument does not exist.
-
disassociate_groups_from_inventory_host
(organization, inventory, hostname, groups)[source]¶ Removes groups from a host.
Parameters: - organization – The name of the organization the inventory belongs to.
- inventory – The inventory which contains the host to affect.
- hostname – The name of the host to remove the groups from.
- groups – A string of a single group or a list or tuple of group names to remove from a host.
Returns: True on complete success, False otherwise.
Return type: bool
Raises: InvalidHost
– The host provided as argument does not exist.
-
external_users
¶ Retrieves only users created by an external system.
Returns: Users created by external system in tower. Return type: users (Generator)
-
get_all_groups_by_host_id
(host_id)[source]¶ Get groups for a particular host, which are directly and indirectly connected.
Parameters: host_id – the id of the given host.. Returns: list of custom groups. Return type: list
-
get_credential_by_id
(id_)[source]¶ Retrieves a credential by id.
Parameters: id – The id of the credential to retrieve. Returns: The credential if a match is found else None. Return type: Host
-
get_credential_type_by_id
(id_)[source]¶ Retrieves a credential_type by id.
Parameters: id – The id of the credential_type to retrieve. Returns: The credential_type if a match is found else None. Return type: Host
-
get_credential_type_by_name
(name)[source]¶ Retrieves a credential_type by name.
Parameters: name – The name of the credential_type to retrieve. Returns: The credential_type if a match is found else None. Return type: Host
-
get_credentials_by_name
(name)[source]¶ Retrieves all credentials matching a certain name.
Parameters: name – The name of the credential(s) to retrieve. Returns: A credentials generator. Return type: Credentials (Generator)
-
get_group_by_id
(id_)[source]¶ Retrieves a group by id.
Parameters: id – The id of the group to retrieve. Returns: The group if a match is found else None. Return type: Group
-
get_host_by_id
(id_)[source]¶ Retrieves a host by id.
Parameters: id – The id of the host to retrieve. Returns: The host if a match is found else None. Return type: Host
-
get_hosts_by_name
(name)[source]¶ Retrieves hosts by name.
Parameters: name – The name of the hosts to retrieve. Returns: A generator with the matching hosts Return type: hosts (Generator)
-
get_inventories_by_name
(name)[source]¶ Retrieves inventories by name.
Parameters: name – The name of the inventories to retrieve. Returns: A generator with the matching inventories Return type: inventories (Generator)
-
get_inventory_by_id
(id_)[source]¶ Retrieves an inventory by id.
Parameters: id – The id of the inventory to retrieve. Returns: The inventory if a match is found else None. Return type: Inventory
-
get_inventory_group_by_name
(organization, inventory, name)[source]¶ Retrieves a group by name.
Parameters: - organization – The name of the organization the inventory belongs to.
- inventory – The inventory to retrieve the group from.
- name – The name of the group to retrieve.
Returns: The group if a match is found else None.
Return type: Raises: InvalidOrganization
– The organisation provided as an argument does not exist.InvalidInventory
– The inventory name provided as an argument does not exist.
-
get_inventory_host_by_name
(organization, inventory, name)[source]¶ Retrieves a host by name from an inventory.
Parameters: - organization – The name of the organization the inventory belongs to.
- inventory – The name of the inventory to search for a host.
- name – The name of the host to retrieve.
Returns: The host if a match is found else None.
Return type:
-
get_job_by_id
(id_)[source]¶ Retrieves a job by id.
Parameters: id – The id of the job to retrieve. Returns: The host if a match is found else None. Return type: Host
-
get_job_template_by_id
(id_)[source]¶ Retrieves a job template by id.
Parameters: id – The id of the job template to retrieve. Returns: The job template if a match is found else None. Return type: Host
-
get_job_template_by_name
(name)[source]¶ Retrieves job_template by name.
Parameters: name – The name of the job_template to retrieve. Returns: A template with the matching name Return type: job_templates (JobTemplate)
-
get_jobs_by_name
(name)[source]¶ Get filtered list of jobs for a given name.
Parameters: name – the given job name. Returns: the filtered list of jobs. Return type: list
-
get_organization_by_id
(id_)[source]¶ Retrieves an organization by id.
Parameters: id – The id of the organization to retrieve. Returns: The organization if a match is found else None. Return type: Organization
-
get_organization_by_name
(name)[source]¶ Retrieves an organization by name.
Parameters: name – The name of the organization to retrieve. Returns: The organization if a match is found else None. Return type: Organization
-
get_organization_credential_by_name
(organization, name, credential_type)[source]¶ Retrieves all credentials matching a certain name.
Parameters: - organization – The organization that owns the credential.
- name – The name of the credential(s) to retrieve.
- credential_type – The type of the credential.
Returns: A credential if found else None.
Return type: Raises: InvalidCredentialType
– The CredentialType given was not found.InvalidOrganization
– The Organization given was not found.
-
get_organization_credential_by_name_with_type_id
(organization, name, credential_type_id)[source]¶ Retrieves all credentials matching a certain name.
Parameters: - organization (str) – The organization that owns the credential.
- name (str) – The name of the credential(s) to retrieve.
- credential_type_id (int) – The integer of the type of the credential.
Returns: A credential if found else None.
Return type: Raises: InvalidOrganization
– The Organization given was not found.
-
get_organization_inventory_by_name
(organization, name)[source]¶ Retrieves an inventory by name from an organization.
Parameters: - organization – The name of the organization to retrieve the inventory from.
- name – The name of the inventory to retrieve.
Returns: The inventory if a match is found else None.
Return type: Raises: InvalidOrganization
– The organization provided as argument does not exist.
-
get_organization_inventory_script_by_name
(organization, name)[source]¶ Retrieves an custom inventory script by name from an organization.
Parameters: - organization – The name of the organization to retrieve the custom inventory script from.
- name – The name of the custom inventory script to retrieve.
Returns: The custom inventory script if a match is found else None.
Return type: Raises: InvalidOrganization
– The organization provided as argument does not exist.
-
get_organization_project_by_name
(organization, name)[source]¶ Retrieves a project by name.
Parameters: - organization – The name of the organization the project belongs to.
- name – The name of the project to retrieve.
Returns: The project if a match is found else None.
Return type:
-
get_organization_team_by_name
(organization, name)[source]¶ Retrieves a team by name.
Parameters: - organization – The name of the organization the team belongs to.
- name – The name of the team to retrieve.
Returns: The team if a match is found else None.
Return type: Raises: InvalidOrganization
– The organization provided as argument does not exist.
-
get_project_by_id
(id_)[source]¶ Retrieves a project by id.
Parameters: id – The id of the project to retrieve. Returns: The project if a match is found else None. Return type: Project
-
get_project_update_by_id
(id_)[source]¶ Retrieves a project_update by id.
Parameters: id – The id of the project_update to retrieve. Returns: The project_update if a match is found else None. Return type: Host
-
get_project_updates_by_name
(name)[source]¶ Retrieves project_updates matching a certain name.
Parameters: name – the given job_update name. Returns: the filtered list of project update jobs. Return type: list
-
get_projects_by_name
(name)[source]¶ Retrieves projects by name.
Parameters: name – The name of the projects to retrieve. Returns: A generator with the matching projects Return type: projects (Generator)
-
get_schedule_by_id
(id_)[source]¶ Retrieves a schedule by id.
Parameters: id – The id of the schedule to retrieve. Returns: The schedule if a match is found else None. Return type: Schedule
-
get_schedule_by_name
(name)[source]¶ Retrieves an schedule by name.
Parameters: name – The name of the schedule to retrieve. Returns: The schedule if a match is found else None. Return type: Schedule
-
get_system_job_by_id
(id_)[source]¶ Retrieves a job by id.
Parameters: id – The id of the job to retrieve. Returns: The job if a match is found else None. Return type: Host
-
get_system_jobs_by_name
(name)[source]¶ Retrieves all system jobs matching a certain name.
Parameters: name – The name of the system job(s) to retrieve. Returns: A system job generator. Return type: UnifiedJob (Generator)
-
get_team_by_id
(id_)[source]¶ Retrieves a team by id.
Parameters: id – The id of the team to retrieve. Returns: The team if a match is found else None. Return type: Team
-
get_teams_by_name
(name)[source]¶ Retrieves teams by name.
Parameters: name – The name of the teams to retrieve. Returns: A generator with the matching teams Return type: teams (Generator)
-
get_unified_job_by_id
(id_)[source]¶ Retrieves a job by id.
Parameters: id – The id of the job to retrieve. Returns: The job if a match is found else None. Return type: Host
-
get_unified_jobs_by_name
(name)[source]¶ Retrieves all unified jobs matching a certain name.
Parameters: name – The name of the unified job(s) to retrieve. Returns: A unified job generator. Return type: UnifiedJob (Generator)
-
get_user_by_id
(id_)[source]¶ Retrieves a user by id.
Parameters: id – The id of the user to retrieve. Returns: The user if a match is found else None. Return type: User
-
get_user_by_username
(name)[source]¶ Retrieves user by name.
Parameters: name – The name of the user to retrieve. Returns: The user if a match is found else None. Return type: user (User)
-
get_workflow_job_by_id
(id_)[source]¶ Retrieves a job by id.
Parameters: id – The id of the job to retrieve. Returns: The job if a match is found else None. Return type: Host
-
get_workflow_job_template_by_id
(id_)[source]¶ Retrieves a workflow template job by id.
Parameters: id – The id of the workflow template job to retrieve. Returns: The job if a match is found else None. Return type: Host
-
get_workflow_job_templates_by_name
(name)[source]¶ Retrieves all workflow template jobs matching a certain name.
Parameters: name – The name of the workflow template job(s) to retrieve. Returns: A workflow template job generator. Return type: UnifiedJob (Generator)
-
get_workflow_jobs_by_name
(name)[source]¶ Retrieves all workflow jobs matching a certain name.
Parameters: name – The name of the workflow job(s) to retrieve. Returns: A workflow job generator. Return type: UnifiedJob (Generator)
-
groups
¶ The groups configured in tower.
Returns: The manager object for groups. Return type: EntityManager
-
hosts
¶ The hosts configured in tower.
Returns: The manager object for hosts Return type: EntityManager
-
instance_groups
¶ The instance_groups configured in tower.
Returns: The manager object for instance groups. Return type: EntityManager
-
instances
¶ The instances configured in tower.
Returns: The manager object for instances. Return type: EntityManager
-
inventories
¶ The inventories configured in tower.
Returns: The inventories configured in tower.` Return type: list of Inventory
-
inventory_scripts
¶ The inventories configured in tower.
Returns: The inventories configured in tower.` Return type: list of Inventory
-
inventory_sources
¶ A manager object for the inventory_sources in tower.
Returns: The manager object for inventory_sources. Return type: EntityManager
-
job_events
¶ The job templates configured in tower.
Returns: The manager object for job templates. Return type: EntityManager
-
job_templates
¶ The job templates configured in tower.
Returns: The manager object for job templates. Return type: EntityManager
-
jobs
¶ The jobs executed in tower.
Returns: The manager object for jobs. Return type: EntityManager
-
local_users
¶ Retrieves only users created locally in tower.
Returns: Users created locally in tower. Return type: users (Generator)
-
notification_templates
¶ The notification templates configured in tower.
Returns: The manager object for groups. Return type: EntityManager
-
organizations
¶ The organizations configured in tower.
Returns: The manager object for organizations. Return type: EntityManager
-
project_updates
¶ A manager object for the project_updates in tower.
Returns: A generator of project updates. Return type: project_updates (EntityManager)
-
projects
¶ The projects configured in tower.
Returns: The manager object for projects. Return type: EntityManager
-
roles
¶ The roles configured in tower.
Returns: The manager object for roles. Return type: EntityManager
-
schedules
¶ The schedules configured in tower.
Returns: The manager object for schedules. Return type: EntityManager
-
settings
¶ The settings part of tower.
Returns: The manager object for settings. Return type: EntityManager
-
system_jobs
¶ The system jobs executed in tower.
Returns: The manager object for system jobs. Return type: EntityManager
-
teams
¶ The teams configured in tower.
Returns: The manager object for teams. Return type: EntityManager
-
tower_credential_types
¶ The default credential_types configured in tower.
Returns: The manager object for internal credential types. Return type: EntityManager
-
unified_job_templates
¶ The unified job templates configured in tower.
Returns: The manager object for unified job templates. Return type: EntityManager
-
unified_jobs
¶ The unified jobs executed in tower.
Returns: The manager object for unified jobs. Return type: EntityManager
-
update_all_organization_projects
(organization_name)[source]¶ Update all the projects in ansible tower for a given organization.
Parameters: organization_name – The name of the organization.
-
update_organization_project_by_name
(organization_name, project_name)[source]¶ Update the ansible tower project with given project name.
Parameters: - organization_name – The name of the organization.
- project_name – The name of the project, which is to be updated.
Returns: dict of response of api request as json on success, None otherwise.
Return type: API Response (dict)
-
update_organization_projects_by_branch_name
(scm_url, branch_name, organization_name)[source]¶ Update an ansible tower project or list of projects for an organization based on their branch name.
A scm_branch can only be identified correctly with a corresponding scm_url.
Parameters: - scm_url – the URL of the relevant repository configured in the project.
- branch_name – the name of the branch, which is selected as scm_branch parameter of the project.
- organization_name – the name of the organization.
-
update_organization_projects_by_scm_url
(scm_url, organization_name)[source]¶ Send update request to update project for a given git repository (scm_url) withing an organization.
Parameters: - organization_name – the name of the organization.
- scm_url – the http url of the required repository.
-
update_project_by_id
(project_id)[source]¶ Update the ansible tower project with given project id.
Parameters: project_id – The id of the project, which is to be updated. Returns: List of response of api request as json on success, None otherwise. Return type: list
-
users
¶ A manager object for the users in tower.
Returns: The manager object for users. Return type: EntityManager
-
workflow_job_templates
¶ The workflow job templates configured in tower.
Returns: The manager object for workflow job templates. Return type: EntityManager
-
workflow_jobs
¶ The workflow jobs executed in tower.
Returns: The manager object for workflow jobs. Return type: EntityManager
-
towerlib.towerlibexceptions module¶
Custom exception code for towerlib.
-
exception
towerlib.towerlibexceptions.
AuthFailed
[source]¶ Bases:
Exception
The token retrieval failed.
-
exception
towerlib.towerlibexceptions.
FailedToDeleteTemplate
[source]¶ Bases:
Exception
The deletion of the job template failed.
-
exception
towerlib.towerlibexceptions.
InvalidCredential
[source]¶ Bases:
Exception
The credential provided is invalid.
-
exception
towerlib.towerlibexceptions.
InvalidCredentialType
[source]¶ Bases:
Exception
The credential type provided is invalid.
-
exception
towerlib.towerlibexceptions.
InvalidGroup
[source]¶ Bases:
Exception
The group provided is invalid.
-
exception
towerlib.towerlibexceptions.
InvalidHost
[source]¶ Bases:
Exception
The host provided is invalid.
-
exception
towerlib.towerlibexceptions.
InvalidInstanceGroup
[source]¶ Bases:
Exception
The instance group provided does not exist.
-
exception
towerlib.towerlibexceptions.
InvalidInventory
[source]¶ Bases:
Exception
The inventory provided is invalid.
-
exception
towerlib.towerlibexceptions.
InvalidInventoryScript
[source]¶ Bases:
Exception
The inventory script provided is invalid.
-
exception
towerlib.towerlibexceptions.
InvalidJobTemplate
[source]¶ Bases:
Exception
The job template provided is not valid.
-
exception
towerlib.towerlibexceptions.
InvalidJobType
[source]¶ Bases:
Exception
The job type provided is not valid. Valid values (u’run’, u’check’).
-
exception
towerlib.towerlibexceptions.
InvalidOrganization
[source]¶ Bases:
Exception
The organization provided is not a valid organization.
-
exception
towerlib.towerlibexceptions.
InvalidPlaybook
[source]¶ Bases:
Exception
The playbook specified does not exist in the project.
-
exception
towerlib.towerlibexceptions.
InvalidProject
[source]¶ Bases:
Exception
The project provided is not valid.
-
exception
towerlib.towerlibexceptions.
InvalidRole
[source]¶ Bases:
Exception
The role is not valid for this organization.
-
exception
towerlib.towerlibexceptions.
InvalidSchedule
[source]¶ Bases:
Exception
The schedule is not valid for this job template.
-
exception
towerlib.towerlibexceptions.
InvalidTeam
[source]¶ Bases:
Exception
The team provided is invalid.
-
exception
towerlib.towerlibexceptions.
InvalidUser
[source]¶ Bases:
Exception
The user provided is invalid.
-
exception
towerlib.towerlibexceptions.
InvalidUserLevel
[source]¶ Bases:
Exception
The value provided is not allowed.
Valid values (‘standard’, ‘system_auditor’, ‘system_administrator’)
-
exception
towerlib.towerlibexceptions.
InvalidValue
[source]¶ Bases:
Exception
The value is not valid for the field.
-
exception
towerlib.towerlibexceptions.
InvalidVariables
[source]¶ Bases:
Exception
The variables are not valid json.