towerlib.entities package¶
Submodules¶
towerlib.entities.core module¶
Main code for miscellaneous.
-
towerlib.entities.core.
Cluster
¶ alias of
towerlib.entities.core.InstanceGroups
-
class
towerlib.entities.core.
ClusterInstance
(tower_instance, name, hearbeat)[source]¶ Bases:
towerlib.entities.core.DateParserMixin
Models the instance of a node as part of the cluster.
-
capacity
¶ The capacity of the node.
-
consumed_capacity
¶ The consumed capacity.
-
created_at
¶ The date and time the entity was created in tower.
Returns: The datetime object of the date and time of the creation of the object. None: If there is no entry for the creation. Return type: datetime
-
heartbeat
¶ Datetime object of when the last heartbeat was recorded.
-
hostname
¶ The hostname of the node.
-
id
¶ The id of the node.
-
jobs_running
¶ The number of running jobs.
-
modified_at
¶ The date and time the entity was modified in tower.
Returns: The datetime object of the date and time of the modification of the object. None: If there is no entry for the modification. Return type: datetime
-
percent_capacity_remaining
¶ The percentage of remaining capacity.
-
uuid
¶ The uuid of the node.
-
version
¶ The version of tower on the node.
-
-
class
towerlib.entities.core.
Config
(eula, license_info, analytics_status, version, project_base_dir, time_zone, ansible_version, project_local_paths)¶ Bases:
tuple
-
analytics_status
¶ Alias for field number 2
-
ansible_version
¶ Alias for field number 6
-
eula
¶ Alias for field number 0
-
license_info
¶ Alias for field number 1
-
project_base_dir
¶ Alias for field number 4
-
project_local_paths
¶ Alias for field number 7
-
time_zone
¶ Alias for field number 5
-
version
¶ Alias for field number 3
-
-
class
towerlib.entities.core.
DateParserMixin
[source]¶ Bases:
object
Implements a string to datetime parsing to be inherited by all needed objects.
-
class
towerlib.entities.core.
Entity
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.DateParserMixin
The basic object that holds common responses across all entities.
-
api_url
¶ The api url of the object.
Returns: The relative url of the representation of the object in tower. Return type: string
-
created_at
¶ The date and time the entity was created in tower.
Returns: The datetime object of the date and time of the creation of the object. None: If there is no entry for the creation. Return type: datetime
-
delete
()[source]¶ Deletes the entity from tower.
Returns: True on success, False otherwise. Return type: bool
-
id
¶ The id of the object.
Returns: The number of the internal id of the object in tower. Return type: int
-
modified_at
¶ The date and time the entity was modified in tower.
Returns: The datetime object of the date and time of the modification of the object. None: If there is no entry for the modification. Return type: datetime
-
type
¶ The type of the object.
Returns: The name of the type of the object in tower. Return type: string
-
url
¶ The url of the object.
Returns: The full url of the representation of the object in tower. Return type: string
-
-
class
towerlib.entities.core.
EntityManager
(tower_instance, entity_object, primary_match_field, entity_name=None, url=None)[source]¶ Bases:
object
Manages entities by making them act like iterables but also implements contains and other useful stuff.
-
filter
(params)[source]¶ Implements filtering based on the filtering capabilities of tower.
Parameters: params – Dictionary of filters to be passed to the api. Returns: Generator of the objects retrieved based on the filtering. https://docs.ansible.com/ansible-tower/latest/html/towerapi/filtering.html.
-
-
class
towerlib.entities.core.
LicenseFeatures
(surveys, multiple_organizations, workflows, system_tracking, enterprise_auth, rebranding, activity_streams, ldap, ha)¶ Bases:
tuple
-
activity_streams
¶ Alias for field number 6
-
enterprise_auth
¶ Alias for field number 4
-
ha
¶ Alias for field number 8
-
ldap
¶ Alias for field number 7
-
multiple_organizations
¶ Alias for field number 1
-
rebranding
¶ Alias for field number 5
-
surveys
¶ Alias for field number 0
-
system_tracking
¶ Alias for field number 3
-
workflows
¶ Alias for field number 2
-
-
class
towerlib.entities.core.
LicenseInfo
(subscription_name, valid_key, features, date_expired, available_instances, hostname, free_instances, instance_count, time_remaining, compliant, grace_period_remaining, trial, company_name, date_warning, license_type, license_key, license_date, deployment_id, current_instances)¶ Bases:
tuple
-
available_instances
¶ Alias for field number 4
-
company_name
¶ Alias for field number 12
-
compliant
¶ Alias for field number 9
-
current_instances
¶ Alias for field number 18
-
date_expired
¶ Alias for field number 3
-
date_warning
¶ Alias for field number 13
-
deployment_id
¶ Alias for field number 17
-
features
¶ Alias for field number 2
-
free_instances
¶ Alias for field number 6
-
grace_period_remaining
¶ Alias for field number 10
-
hostname
¶ Alias for field number 5
-
instance_count
¶ Alias for field number 7
-
license_date
¶ Alias for field number 16
-
license_key
¶ Alias for field number 15
-
license_type
¶ Alias for field number 14
-
subscription_name
¶ Alias for field number 0
-
time_remaining
¶ Alias for field number 8
-
trial
¶ Alias for field number 11
-
valid_key
¶ Alias for field number 1
-
-
towerlib.entities.core.
validate_characters
(value, alpha=True, numbers=True, extra_chars=None)[source]¶ Validates the string groups of a value.
-
towerlib.entities.core.
validate_json
(value)[source]¶ Validates that the provided value is a valid json.
towerlib.entities.credential module¶
Main code for credentials.
-
class
towerlib.entities.credential.
AmazonWebServicesCredential
(tower_instance, data)[source]¶ Bases:
towerlib.entities.credential.GenericCredential
Models the Amazon Web Services credential.
-
access_key
¶ The access_key that is set in the credential.
Returns: The access_key that is set in the credential. Return type: basestring
-
secret_key
¶ The secret_key that is set in the credential.
Returns: The secret_key that is set in the credential. Return type: basestring
-
-
class
towerlib.entities.credential.
Credential
[source]¶ Bases:
object
Credential factory to handle the different credential types returned.
-
class
towerlib.entities.credential.
CredentialType
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the credential_type entity of ansible tower.
-
description
¶ The description of the credential type.
Returns: The description of the credential type. Return type: string
-
injectors
¶ The injectors of the credential type.
Returns: A structure of the credential type supported injectors. Return type: dictionary
-
input_sources
¶ The input sources of the credential.
Returns: A structure of the credential input sources. Return type: dictionary
-
inputs
¶ The inputs of the credential type.
Returns: A structure of the credential type supported inputs. Return type: dictionary
-
kind
¶ The kind of the credential type.
Accepted values are : (u’scm’, u’ssh’, u’vault’, u’net’, u’cloud’, u’insights’).
Returns: The kind of the credential type. Return type: string
-
managed_by_tower
¶ Flag indicating whether the credential is internal to tower.
Returns: True if credential is internal to tower, False if it is user created. Return type: bool
-
name
¶ The name of the credential type.
Returns: The name of the credential type. Return type: string
-
-
class
towerlib.entities.credential.
GenericCredential
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the credential entity of ansible tower.
-
created_by
¶ The user that created the credential.
Returns: The user that created the credential. Return type: User
-
credential_type
¶ The type of the credential.
Returns: The type of the credential. Return type: CredentialType
-
description
¶ The description of the credential.
Returns: The description of the credential. Return type: string
-
host
¶ The host of the credential.
Returns: The host structure of the credential. Return type: dictionary
-
inputs
¶ The inputs of the credential.
Returns: A structure of the credential supported inputs. Return type: dictionary
-
modified_by
¶ The person that modified the credential last.
Returns: The user that modified the credential in tower last. Return type: User
-
name
¶ The name of the credential.
Returns: The name of the credential. Return type: string
-
object_roles
¶ The object roles.
Returns: EntityManager of the object roles supported. Return type: EntityManager
-
organization
¶ The organization the credential is part of.
Returns: The organization the credential is part of. Return type: Organization
-
owner_teams
¶ The owner teams of the credential.
Returns: EntityManager of the teams that are owners. Return type: EntityManager
-
owner_users
¶ The owners of the credential.
Returns: EntityManager of the users that are owners. Return type: EntityManager
-
project
¶ The project of the credential.
Returns: The project structure of the credential. Return type: dictionary
-
-
class
towerlib.entities.credential.
HashicorpVaultCredential
(tower_instance, data)[source]¶ Bases:
towerlib.entities.credential.GenericCredential
Models the hashicorp vault credential.
-
ca_host_verify
¶ The ca host verify setting that is set in the credential.
Returns: The vault address that is set in the credential. Return type: basestring
-
token
¶ The token that is set in the credential.
Returns: The token that is set in the credential. Return type: basestring
-
vault_address
¶ The vault address that is set in the credential.
Returns: The vault address that is set in the credential. Return type: basestring
-
-
class
towerlib.entities.credential.
MachineCredential
(tower_instance, data)[source]¶ Bases:
towerlib.entities.credential.GenericCredential
Models the machine credential.
-
password
¶ The password that is set in the credential.
Returns: The password that is set in the credential. Return type: basestring
-
username
¶ The username that is set in the credential.
Returns: The username that is set in the credential. Return type: basestring
-
towerlib.entities.group module¶
Main code for group.
-
class
towerlib.entities.group.
Group
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the group entity of ansible tower.
-
add_host_by_name
(name)[source]¶ Add a host to the group by name.
Parameters: name – The name of the host to add to the group. Returns: True on success, False otherwise. Return type: bool Raises: InvalidHost
– The host provided as argument does not exist.
-
associate_group_by_name
(name)[source]¶ Associate a group to the group by name.
Parameters: name – The name of the group to associate with the group. Returns: True on success, False otherwise. Return type: bool Raises: InvalidGroup
– The group provided as argument does not exist.
-
created_by
¶ The user that created the group.
Returns: The user that created the group. Return type: User
-
description
¶ The description of the group.
Returns: The description of the group. Return type: string
-
disassociate_group_by_name
(name)[source]¶ Disassociate a group from the group.
Parameters: name – The name of the group to disassociate. Returns: True on success, False otherwise. Return type: bool Raises: InvalidGroup
– The group provided as argument does not exist.
-
groups
¶ The associated groups of the group.
Returns: EntityManager of the groups of the group. Return type: EntityManager
-
groups_with_active_failures_count
¶ The number of groups with active failures.
Returns: The number of groups with active failures. Return type: integer
-
has_active_failures
¶ A flag on whether the group has active failures.
Returns: True if there are active failures, False if not. Return type: bool
-
has_inventory_sources
¶ A flag of whether there are.
Returns: True if set, False otherwise. Return type: bool
-
hosts
¶ The hosts of the group.
Returns: EntityManager of the hosts of the group. Return type: EntityManager
-
hosts_with_active_failures_count
¶ The number of hosts with active failures.
Returns: The number of hosts with active failures. Return type: integer
-
inventory
¶ The inventory that the group is part of.
Returns: The inventory that the group is part of. Return type: Inventory
-
name
¶ The name of the group.
Returns: The name of the group. Return type: string
-
remove_host_by_name
(name)[source]¶ Removes a host from the group.
Parameters: name – The name of the host to remove. Returns: True on success, False otherwise. Return type: bool Raises: InvalidHost
– The host provided as argument does not exist.
-
total_groups_count
¶ The number of groups.
Returns: The number of groups. Return type: integer
-
total_hosts_count
¶ The total number of hosts in the group.
Returns: The number of group hosts. Return type: integer
-
variables
¶ The variables set on the group.
Returns: A string of the variables set on the group usually in yaml format. Return type: string
-
towerlib.entities.host module¶
Main code for host.
-
class
towerlib.entities.host.
Host
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the host entity of ansible tower.
-
all_groups
¶ The groups that the host is directly and indirectly part of.
Returns: EntityManager of the groups of the host. Return type: EntityManager
-
ansible_facts
¶ Returns ansible facts gathered about the host in json.
Args: None
Returns: Json representation of ansible facts Return type: json Raises: None
-
associate_with_groups
(groups)[source]¶ Associate the host with the provided groups.
Parameters: - groups – The groups to associate the host with.
- a single group string or a list or tuple of groups. (Accepts) –
Returns: True on complete success, False otherwise.
Return type: bool
Raises: InvalidGroup
– The group provided as argument does not exist.
-
created_by
¶ The user that created the host.
Returns: The user that created the host. Return type: User
-
description
¶ The description of the host.
Returns: The description of the host. Return type: string
-
disassociate_with_groups
(groups)[source]¶ Disassociate the host from the provided groups.
Parameters: - groups – The group name(s) to disassociate the host from.
- a single group string or a list or tuple of groups. (Accepts) –
Returns: True on complete success, False otherwise.
Return type: bool
Raises: InvalidGroup
– The group provided as argument does not exist.
-
enabled
¶ Flag about whether the host is enabled in tower.
Returns: True if the host is enabled, False otherwise. Return type: bool
-
groups
¶ The groups that the host is part of.
Returns: EntityManager of the groups of the host. Return type: EntityManager
-
has_active_failures
¶ Flag about whether the host has active failures.
Returns: True if the host has active failures, False otherwise. Return type: bool
-
has_inventory_sources
¶ Flag about whether the host has inventory sources.
Returns: True if the host has inventory sources, False otherwise. Return type: bool
-
insights_system_id
¶ Not sure what this is.
Returns: None.
-
instance_id
¶ Not sure what this is.
Returns: Return type: string
-
inventory
¶ The inventory that the host is part of.
Returns: The inventory that the host is part of. Return type: Inventory
-
job_events
¶ The job_events for the host.
Returns: All job events of the host Return type: job_events (list)
-
last_job
¶ The id of the last job.
Returns: The id of the last job. Return type: integer
-
last_job_host_summary
¶ The id of the last job summary.
Returns: The id of the last job summary.. Return type: integer
-
modified_by
¶ The person that modified the host last.
Returns: The user that modified the host in tower last. Return type: User
-
name
¶ The name of the host.
Returns: The name of the host. Return type: string
-
recent_jobs
¶ The most recent jobs run on the host.
Returns: The most recent jobs run on the host. Return type: list if dict
-
variables
¶ The variables set on the host.
Returns: A string of the variables set on the host usually in yaml format. Return type: string
-
towerlib.entities.instance module¶
Main code for instances.
-
class
towerlib.entities.instance.
Instance
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the instance entity of ansible tower.
-
capacity
¶ Not really sure what this is.
Returns: Return type: integer
-
consumed_capacity
¶ Not really sure what this is.
Returns: Return type: integer
-
hostname
¶ The hostname of the instance.
Returns: The hostname of the instance. Return type: string
-
jobs
¶ The jobs of the instance.
Returns: EntityManager of the jobs of the instance. Return type: EntityManager
-
jobs_running_count
¶ The number of running jobs.
Returns: The number of running jobs. Return type: integer
-
percent_capacity_remaining
¶ Not really sure what this is.
Returns: Return type: integer
-
uuid
¶ The uuid of the instance.
Returns: The uuid of the instance. Return type: string
-
version
¶ The version of the instance.
Returns: The version of the instance. Return type: string
-
-
class
towerlib.entities.instance.
InstanceGroup
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the instance_group entity of ansible tower.
-
capacity
¶ Not really sure what this is.
Returns: Return type: integer
-
consumed_capacity
¶ Not really sure what this is.
Returns: Return type: integer
-
controller
¶ Not really sure what this is.
Returns: None.
-
instances
¶ The instances of the instance group.
Returns: The instances of the instance group. Return type: list of Instances
-
instances_count
¶ The number of instances.
Returns: The number of instances. Return type: integer
-
jobs_running_count
¶ The number of running jobs.
Returns: The number of running jobs. Return type: integer
-
name
¶ The name of the instance group.
Returns: The name of the instance group. Return type: string
-
percent_capacity_remaining
¶ Not really sure what this is.
Returns: Return type: integer
-
towerlib.entities.inventory module¶
Main code for inventory.
-
class
towerlib.entities.inventory.
Inventory
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the inventory entity of ansible tower.
-
create_group
(name, description, variables='{}')[source]¶ Creates a group.
Parameters: - name – The name of the group to create.
- description – The description of the group.
- variables – A json with the variables that will be set on the created group.
Returns: The created group is successful, None otherwise.
Return type: Raises: InvalidVariables
– The variables provided as argument is not valid json.
-
create_host
(name, description, variables='{}')[source]¶ Creates a host.
Parameters: - name – The name of the host to create.
- description – The description of the host.
- variables – A json with the variables that will be set on the created host.
Returns: The created host is successful, None otherwise.
Return type: Raises: InvalidVariables
– The variables provided as argument is not valid json.
-
create_source
(name, description, source='scm', source_path='', source_script=None, source_vars='', credential='', credential_type='', source_regions='', instance_filters='', group_by='', overwrite=True, overwrite_vars=True, timeout=0, verbosity=1, update_on_launch=True, update_cache_timeout=0, source_project='', update_on_project_update=False)[source]¶ Creates a source.
Parameters: - () (update_on_project_update) –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
Returns: bool
-
create_source_with_credential_id
(name, description, credential_id, source='scm', source_path='', source_script=None, source_vars='', source_regions='', instance_filters='', group_by='', overwrite=True, overwrite_vars=True, timeout=0, verbosity=1, update_on_launch=True, update_cache_timeout=0, source_project='', update_on_project_update=False)[source]¶ Creates Source with credential id.
Parameters: - () (update_on_project_update) –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
- () –
Returns: bool
-
created_by
¶ The user that created the inventory.
Returns: The user that created the inventory. Return type: User
-
delete_group
(name)[source]¶ Deletes the group.
Parameters: 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_host
(name)[source]¶ Deletes the host.
Parameters: 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.
-
description
¶ The description of the inventory.
Returns: The description of the inventory. Return type: string
-
get_group_by_name
(name)[source]¶ Retrieves the group.
Parameters: name – The name of the group to retrieve. Returns: returns a group if found else None. Return type: group (Group) Raises: InvalidGroup
– The group provided as argument does not exist.
-
get_host_by_name
(name)[source]¶ Retrieves a host.
Parameters: name – The name of the host to retrieve. Returns: returns a host if found else None. Return type: host (Host) Raises: InvalidHost
– The host provided as argument does not exist.
-
groups
¶ The groups of the inventory.
Returns: The groups of the inventory. Return type: list of Group
-
groups_with_active_failures_count
¶ The number of groups with active failures.
Returns: The number of groups with active failures. Return type: integer
-
has_active_failures
¶ A flag on whether the inventory has active failures.
Returns: True if there are active failures, False if not. Return type: bool
-
has_inventory_sources
¶ A flag of whether there are.
Returns: True if set, False otherwise. Return type: bool
-
host_filter
¶ Not sure what this does.
Returns: The host filter. Return type: string
-
hosts
¶ The hosts of the inventory.
Returns: The hosts of the inventory. Return type: list of Host
-
hosts_with_active_failures_count
¶ The number of hosts with active failures.
Returns: The number of hosts with active failures. Return type: integer
-
insights_credential
¶ Not sure what this is.
Returns: None.
-
inventory_sources_with_failures_count
¶ The number of sources with failures.
Returns: The number of sources with failures. Return type: integer
-
kind
¶ The kind of inventory.
Returns: The kind of inventory. Return type: string
-
name
¶ The name of the inventory.
Returns: The name of the inventory. Return type: string
-
object_role_names
¶ The names of the object roles.
Returns: A list of strings for the object_roles. Return type: list
-
object_roles
¶ The object roles.
Returns: EntityManager of the object roles supported. Return type: EntityManager
-
organization
¶ The organization the inventory is part of.
Returns: The organization the inventory is part of. Return type: Organization
-
pending_deletion
¶ Whether the invertory is pending deletion.
Returns: True if it is, False otherwise. Return type: bool
-
sources
¶ The inventory_sources of the inventory.
Returns: The inventory_sources of the inventory. Return type: list of Host
-
total_groups_count
¶ The number of groups.
Returns: The number of groups. Return type: integer
-
total_hosts_count
¶ The total number of hosts in the inventory.
Returns: The number of inventory hosts. Return type: integer
-
total_inventory_sources_count
¶ The number of sources.
Returns: The number of sources. Return type: integer
-
variables
¶ The variables set on the inventory.
Returns: A string of the variables set on the inventory usually in yaml format. Return type: string
-
towerlib.entities.inventory_script module¶
Main code for inventory_script.
-
class
towerlib.entities.inventory_script.
InventoryScript
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the inventory script entity of ansible tower.
-
description
¶ The description of the inventory script.
Returns: The description of the inventory script. Return type: string
-
name
¶ The name of the inventory script.
Returns: The name of the inventory script. Return type: string
-
script
¶ The script of the inventory script.
Returns: The script of the inventory script. Return type: string
-
towerlib.entities.inventory_source module¶
Main code for inventory_source.
-
class
towerlib.entities.inventory_source.
InventorySource
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the inventory source entity of ansible tower.
-
description
¶ The description of the inventory source.
Returns: The description of the inventory source. Return type: string
-
instance_filters
¶ The instance_filters of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
inventory
¶ The inventory of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
name
¶ The name of the inventory source.
Returns: The name of the inventory source. Return type: string
-
overwrite
¶ The overwrite of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
overwrite_vars
¶ The overwrite_vars of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
source
¶ The source of the inventory source.
Returns: The source of the inventory source. Return type: string
-
source_path
¶ The source_path of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
source_project
¶ The source_project of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
source_regions
¶ The source_regions of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
source_script
¶ The source_script of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
source_vars
¶ The source_vars of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
timeout
¶ The timeout of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
update_cache_timeout
¶ The update_cache_timeout of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
update_on_launch
¶ The update_on_launch of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
update_on_project_update
¶ The update_on_project_update of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
verbosity
¶ The verbosity of the inventory source.
Returns: The source path of the inventory source. Return type: string
-
towerlib.entities.job module¶
Main code for jobs.
-
class
towerlib.entities.job.
AdHocCommandJob
(tower_instance, data)[source]¶ Bases:
towerlib.entities.job.SystemJob
Models the project update entity of ansible tower.
-
become_enabled
¶ Boolean on whether the job has become enabled.
Returns: Boolean on whether the job has become enabled. Return type: bool
-
credential
¶ The credential of the job.
Returns: The credential of the job. Return type: Credential
-
diff_mode
¶ Boolean on whether the job has diff mode enabled.
Returns: Boolean on whether the job has diff mode enabled. Return type: bool
-
forks_count
¶ Number of forks supported by the job.
Returns: Number of forks supported by the job. Return type: integer
-
module_args
¶ The arguments passed to the module.
Returns: The arguments passed to the module. Return type: basestring
-
module_name
¶ The name of the module executed.
Returns: The name of the module executed. Return type: basestring
-
-
class
towerlib.entities.job.
Job
[source]¶ Bases:
object
Job factory to handle the different job types returned.
-
class
towerlib.entities.job.
JobEvent
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the job event entity of ansible tower.
-
counter
¶ The counter of the event.
Returns: The counter of the event. Return type: integer
-
created_at
¶ The created date of the event.
Returns: The string formatted datetime of the event creation. Return type: date_time (string)
-
end_line
¶ The end line of the event.
Returns: The end line of the event. Return type: integer
-
event
¶ The name of the host.
Returns: The name of the event. Return type: string
-
event_data
¶ The data of the event.
Returns: The data of the event. Return type: basestring
-
event_display
¶ The display of the event.
Returns: The display of the event. Return type: basestring
-
event_level
¶ The level of the event.
Returns: The level of the event. Return type: integer
-
host
¶ The host of the event.
Returns: The host of the event. Return type: basestring
-
host_name
¶ The hostname of the event.
Returns: The hostname of the event. Return type: basestring
-
is_changed
¶ Whether the event is changed.
Returns: Whether the event is changed. Return type: bool
-
is_failed
¶ Whether the event is failed.
Returns: Whether the event is failed. Return type: bool
-
modified_at
¶ The modified date of the event.
Returns: The string formatted datetime of the event’s last modification. Return type: basestring
-
parent
¶ The parent of the event.
Returns: The parent of the event. Return type: basestring
-
parent_uuid
¶ The parent uuid of the event.
Returns: The parent uuid of the event. Return type: basestring
-
play
¶ The play of the event.
Returns: The play of the event. Return type: basestring
-
playbook
¶ The playbook of the event.
Returns: The playbook of the event. Return type: basestring
-
role
¶ The role of the event.
Returns: The role of the event. Return type: basestring
-
start_line
¶ The start line of the event.
Returns: The start line of the event. Return type: integer
-
stdout
¶ The stdout of the event.
Returns: The stdout of the event. Return type: basestring
-
task
¶ The task of the event.
Returns: The task of the event. Return type: basestring
-
uuid
¶ The uuid of the event.
Returns: The uuid of the event. Return type: basestring
-
verbosity
¶ The verbosity of the event.
Returns: The verbosity of the event. Return type: integer
-
-
class
towerlib.entities.job.
JobRun
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the Job entity of ansible tower.
-
created_by
¶ The User that created the job.
Returns: The user that created the job in tower. Return type: User
-
credentials
¶ The credentials of this job.
Returns: The credentials this job has. Return type: Credentials
-
description
¶ The description of the job.
Returns: The description of the job. Return type: string
-
elapsed_time
¶ The elpsed time of the job.
Returns: The seconds elapsed since the start of the job. Return type: elapsed
-
extra_credentials
¶ The extra credentials of the job.
Returns: EntityManager of the extra credentials. Return type: EntityManager
-
extra_vars
¶ The extra_vars of the job.
Returns: The extra_vars of the job Return type: extra_vars
-
finished
¶ The finished datetime of the job.
Returns: The datetime of the end of the job. Return type: finished_datetime
-
host
¶ The host of the credential.
Returns: The host structure of the credential. Return type: dictionary
-
inventory
¶ The inventory this job belongs to.
Returns: The inventory this job belongs to. Return type: Inventory
-
job_events
¶ The job events of the runs of this job.
Returns: EntityManager of the job events. Return type: EntityManager
-
job_host_summaries
¶ The job summaries of the runs of this job.
Returns: EntityManager of the job host summaries. Return type: EntityManager
-
job_template
¶ The job template of this job.
Returns: The job template of this job. Return type: JobTemplate
-
job_type
¶ The type of the job.
Returns: The type of the job. Return type: string
-
modified_at
¶ The modification datetime of the job.
Returns: The datetime of the modification. Return type: modification_datetime
-
name
¶ The name of the job.
Returns: The name of the job. Return type: string
-
project
¶ The project this job belongs to.
Returns: The project this job belongs to. Return type: Project
-
result_stdout
¶ The result stdout of the job.
Returns: The result stdout of the job. Return type: result_stdout
-
result_traceback
¶ The result traceback of the job.
Returns: The result traceback of the job. Return type: result_traceback
-
status
¶ The status of the job.
Returns: The status of the job. Return type: status
-
stdout
¶ The stdout of the job execution.
Returns: The stdout of the job execution. Return type: basestring
-
summary_fields
¶ The summary fields of the job.
Returns: The summary fields of the job. Return type: dict
-
unified_job_template
¶ The job template this job belongs to.
Returns: The job template this job belongs to. Return type: JobTemplate
-
-
class
towerlib.entities.job.
JobSummary
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the Job entity of ansible tower.
-
failed
¶ Whether the job is failed or not.
Returns: Whether the job is failed or not. Return type: bool
-
failures_count
¶ The number of job failures.
Returns: The number of job failures. Return type: integer
-
host
¶ The host of the job summary.
Returns: The host of the job summary. Return type: basestring
-
host_name
¶ The host name of the job summary.
Returns: The host name of the job summary. Return type: basestring
-
is_changed
¶ Whether the job had been changed.
Returns: Whether the job had been changed. Return type: integer
-
is_dark
¶ Whether the job is dark.
Returns: Whether the job is dark. Return type: integer
-
is_ok
¶ Whether the job is dark.
Returns: Whether the job is dark. Return type: integer
-
processed_count
¶ The number of time the job was processed.
Returns: The number of time the job was processed. Return type: integer
-
skipped_count
¶ The number of time the job was skipped.
Returns: The number of time the job was skipped. Return type: integer
-
summary_fields
¶ The summary_fields of this job summary.
Returns: The summary_fields of this job summary. Return type: dict
-
-
class
towerlib.entities.job.
JobTemplate
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the Job Template entity of ansible tower.
-
add_credential
(credential, credential_type='Machine')[source]¶ Adds credential by name.
Parameters: - credential (str) – A single string of a credential.
- credential_type (int) – The type of the credential.
-
add_credential_by_id
(credential_id)[source]¶ Adds credential by id.
Parameters: credential_id (int) – The id of the credential.
-
add_schedule
(name, start_date, start_time, limit='', description='', time_zone='Europe/Berlin', repeat_frequency='DAILY', interval=1, extra_vars: dict = None)[source]¶ Adds a schedule to a job template.
Parameters: - name (str) – A name of the schedule.
- start_date (datetime.date) – The start date of the schedule
- start_time (datetime.time) – Start time of the schedule
- limit (str) – Limit of the schedule
- description (str) – Description of the schedule
- time_zone (str) – The time zone assigned to the schedule
- repeat_frequency (str) – How frequently the job will be run
- interval (int) – Interval of the Job
- extra_vars (dict) – Variables of the schedule
-
allow_simultaneous
¶ Flag about whether to allow simultaneous executions.
Returns: True if set to allow simultaneous executions , False otherwise. Return type: bool
-
ask_credential_on_launch
¶ Flag about whether to ask for credential on launch.
Returns: True if set to ask for credential on launch, False otherwise. Return type: bool
-
ask_diff_mode_on_launch
¶ Flag about whether to ask for diff mode on launch.
Returns: True if set to ask for diff mode on launch, False otherwise. Return type: bool
-
ask_inventory_on_launch
¶ Flag about whether to ask for inventory on launch.
Returns: True if set to ask for inventory on launch, False otherwise. Return type: bool
-
ask_job_type_on_launch
¶ Flag about whether to ask for job type on launch.
Returns: True if set to ask for job type on launch, False otherwise. Return type: bool
-
ask_limit_on_launch
¶ Flag about whether to ask for limit on launch.
Returns: True if set to ask for limit on launch, False otherwise. Return type: bool
Flag about whether to ask to skip tags on launch.
Returns: True if set to ask to skip tags on launch, False otherwise. Return type: bool
Flag about whether to ask for tags on launch.
Returns: True if set to ask for tags on launch, False otherwise. Return type: bool
-
ask_variables_on_launch
¶ Flag about whether to ask for variables on launch.
Returns: True if set to ask for variables on launch, False otherwise. Return type: bool
-
ask_verbosity_on_launch
¶ Flag about whether to ask for verbosity on launch.
Returns: True if set to ask for verbosity on launch, False otherwise. Return type: bool
-
become_enabled
¶ Not really sure what this is.
Returns: Return type: bool
-
created_by
¶ The User that created the job template.
Returns: The user that created the job template in tower. Return type: User
-
credentials
¶ The credentials that the job template uses.
Returns: The credentials that the job template uses. Return type: Credentials
-
description
¶ The description of the job template.
Returns: The description of the job template. Return type: string
-
diff_mode
¶ Flag about whether the diff mode is enabled.
Returns: True if diff mode is enabled, False otherwise. Return type: bool
-
extra_credentials
¶ The extra_credentials that the job template uses.
Returns: EntityManager of the extra credentials. Return type: EntityManager
-
extra_vars
¶ The extra vars of the job template.
Returns: The extra vars of the job template. Return type: string
-
force_handlers
¶ Flag about whether the handlers are forced.
Returns: True if the handlers are forced, False otherwise. Return type: bool
-
forks_count
¶ The number of forks of the job template.
Returns: The number of forks of the job template. Return type: string
-
host_config_key
¶ Not really sure what this is.
Returns: Return type: string
-
inventory
¶ The inventory that the job template is part of.
Returns: The inventory that the job template is part of. Return type: Inventory
-
is_last_job_failed
¶ Flag about whether the last job failed.
Returns: True if last run job failed, False otherwise. Return type: bool
The job tags of the job template.
Returns: The job tags of the job template. Return type: string
-
job_type
¶ The job_type of the job template.
Returns: The job_type of the job template. Return type: string
-
labels
¶ The labels of the job template.
Returns: The job template labels (only id and name can be retrieved). Return type: labels (list)
-
last_job_run_at
¶ Date and time that the last job template job was run.
Returns: The datetime of the last job execution. Return type: datetime
-
last_job_run_id
¶ The id of most recent job run on the template.
Returns: The id of the most recent job run on the template Return type: int/None
-
launch
(extra_vars=None, job_tags=None, limit=None, inventory=None, credential=None, credentials=None, scm_branch=None, verbosity=None, skip_tags=None, job_type=None, diff_mode=None)[source]¶ Launches the job template.
https://docs.ansible.com/ansible-tower/latest/html/towerapi/launch_jobtemplate.html.
Returns: Job object of the running job on success, None otherwise. Return type: Job
-
limit
¶ The limit of the job template.
Returns: The limit of the job template. Return type: string
-
modified_by
¶ The User that modified the job template last.
Returns: The user that modified the job template in tower last. Return type: User
-
name
¶ The name of the job template.
Returns: The name of the job template. Return type: string
-
next_job_run_at
¶ Date and time when the next job template job will run.
Returns: The datetime of the next job execution. Return type: datetime
-
object_roles
¶ The object roles.
Returns: The object roles supported. Return type: ObjectRole
-
playbook
¶ The playbook of the job template.
Returns: The playbook of the job template. Return type: string
-
project
¶ The project that the job template is part of.
Returns: The project that the job template is part of. Return type: Inventory
-
recent_jobs
¶ The most recent jobs on the template.
Returns: The most recent jobs run on the template. Return type: list if dict
-
schedules
¶ The schedules that the job template uses.
Returns: EntityManager of the schedules. Return type: EntityManager
-
set_inventory
(organization, name)[source]¶ Inventory from specified organization applied as a prompt, assuming job template prompts for inventory.
Parameters: - organization (str) – The organization name the inventory belongs to
- name (str) – The inventory name to set. To reset the inventory set it to empty string.
Returns: None.
The tags to skip for the job template.
Returns: The tags to skip for the job template. Return type: string
-
start_at_task
¶ Not really sure what this is.
Returns: Return type: string
-
status
¶ The status of the job template.
Returns: The status of the job template. Return type: string
-
summary_fields
¶ The summary fields of the job template.
Returns: The summary fields of the job template. Return type: dict
-
survey_enabled
¶ Flag about whether the survey mode is enabled.
Returns: True if survey mode is enabled, False otherwise. Return type: bool
-
survey_spec
¶ Survey specification.
Returns: Dict that contains info about the linked survey if exists Return type: dict
-
timeout
¶ The timeout setting of the job template.
Returns: The timeout setting of the job template. Return type: integer
-
use_fact_cache
¶ Flag about whether the fact cache should be used.
Returns: True if the fact cache should be used, False otherwise. Return type: bool
-
vault_credential
¶ The vault credential of the job template.
Returns: The vault credential of the job template. Return type: string
-
verbosity
¶ The verbosity level of the job template.
Returns: The verbosity level of the job template. Return type: string
-
-
class
towerlib.entities.job.
ProjectUpdateJob
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the project update entity of ansible tower.
-
credentials
¶ The credentials of the project.
Returns: The credentials of the project. Return type: Credentials
-
description
¶ The description of the project for the update.
Returns: The description of the project for the update. Return type: basestring
-
elapsed
¶ The time elapsed during the run.
Returns: The time elapsed during the run. Return type: float
-
execution_node
¶ The node the job got executed on.
Returns: The node the job got executed on. Return type: basestring
-
finished_at
¶ The date and time the update was finished.
Returns: The date and time the update was finished. None: If there is no entry for the finish time. Return type: datetime
-
is_failed
¶ The status of the update.
Returns: The status of the update. Return type: bool
-
job_args
¶ The arguments passed to the execution of the job.
Returns: The arguments passed to the execution of the job. Return type: basestring
-
job_cwd
¶ The current working directory of the execution of the job.
Returns: The current working directory of the execution of the job. Return type: basestring
-
job_env
¶ The environment of the execution of the job.
Returns: The environment of the execution of the job. Return type: dict
-
job_explanation
¶ The explanation of the job.
Returns: The explanation of the job. Return type: basestring
-
job_type
¶ The type of the job executed on the update.
Returns: The type of the job executed on the update. Return type: basestring
-
launch_type
¶ The type of launching for the update.
Returns: The type of launching for the update. Return type: basestring
-
local_path
¶ The local path of the project for the update.
Returns: The local path of the project for the update. Return type: basestring
-
name
¶ The name of the project for the update.
Returns: The name of the project for the update. Return type: basestring
-
project
¶ The project of the ProjectUpdateJob.
Returns: The Project that this project_update belongs to. Return type: Project
-
result_stdout
¶ The stdout of the result of the job.
Returns: The stdout of the result of the job. Return type: basestring
-
result_traceback
¶ The traceback of the result.
Returns: The traceback of the result. Return type: basestring
-
scm_branch
¶ The scm branch of the project for the update.
Returns: The scm branch of the project for the update. Return type: basestring
-
scm_clean
¶ Whether the scm clean flag is set on the project.
Returns: Whether the scm clean flag is set on the project. Return type: bool
-
scm_delete_on_update
¶ Whether the scm delete on update flag is set on the project.
Returns: Whether the scm delete on update flag is set on the project. Return type: bool
-
scm_type
¶ The scm type of the project for the update.
Returns: The scm type of the project for the update. Return type: basestring
-
scm_url
¶ The scm url of the project for the update.
Returns: The scm url of the project for the update. Return type: basestring
-
started_at
¶ The date and time the update was started.
Returns: The date and time the update was started. None: If there is no entry for the start time. Return type: datetime
-
status
¶ The status of the update.
Returns: The status of the update. Return type: basestring
-
stdout
¶ The stdout of the project update.
Returns: The stdout of the project update. Return type: basestring
-
summary_fields
¶ The summary fields of the job.
Returns: The summary fields of the job. Return type: dict
-
timeout
¶ Timeout setting of the project.
Returns: Timeout setting of the project. Return type: integer
-
-
class
towerlib.entities.job.
SystemJob
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the Job entity of ansible tower.
-
description
¶ The description of the job.
Returns: The description of the job. Return type: string
-
elapsed
¶ The time elapsed during the run.
Returns: The time elapsed during the run. Return type: float
-
execution_node
¶ The node the job got executed on.
Returns: The node the job got executed on. Return type: basestring
-
extra_vars
¶ The extra vars of the job template.
Returns: The extra vars of the job template. Return type: string
-
finished_at
¶ The date and time the job was finished.
- Returns:_
- datetime: The datetime object of the date and time of the end of the job. None: If there is no entry for the finish.
-
is_failed
¶ The status of the update.
Returns: The status of the update. Return type: bool
-
job_args
¶ The arguments passed to the execution of the job.
Returns: The arguments passed to the execution of the job. Return type: basestring
-
job_cwd
¶ The current working directory of the execution of the job.
Returns: The current working directory of the execution of the job. Return type: basestring
-
job_env
¶ The environment of the execution of the job.
Returns: The environment of the execution of the job. Return type: dict
-
job_explanation
¶ The explanation of the job.
Returns: The explanation of the job. Return type: basestring
-
job_type
¶ The type of the job.
Returns: The type of the job. Return type: string
-
launch_type
¶ The type of launching for the update.
Returns: The type of launching for the update. Return type: basestring
-
name
¶ The name of the job.
Returns: The name of the job. Return type: string
-
result_stdout
¶ The stdout of the result of the job.
Returns: The stdout of the result of the job. Return type: basestring
-
result_traceback
¶ The traceback of the result.
Returns: The traceback of the result. Return type: basestring
-
started_at
¶ The date and time the job was started.
- Returns:_
- datetime: The datetime object of the date and time of the start of the job. None: If there is no entry for the start.
-
status
¶ The status of the update.
Returns: The status of the update. Return type: basestring
-
summary_fields
¶ The summary fields of the job.
Returns: The summary fields of the job. Return type: dict
-
-
class
towerlib.entities.job.
WorkflowJobRun
(tower_instance, data)[source]¶ Bases:
towerlib.entities.job.JobRun
Models the Workflow Job Run entity of ansible tower.
-
workflow_nodes
¶ Workflow nodes is resouce belonging to a Workflow job.
Returns: This resouce belonging to a Workflow job. Return type: WorkflowNodes
-
-
class
towerlib.entities.job.
WorkflowNodes
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the Workflow nodes entity of ansible tower.
-
count
¶ Number of workflow nodes.
Returns: Number of workflow nodes. Return type: integer
-
next
¶ The next and previous fields provides links to additional results if there are more than will fit on a single page.
Returns: url of next page. Return type: string
-
previous
¶ The next and previous fields provides links to additional results if there are more than will fit on a single page.
Returns: url of previous page. Return type: string
-
results
¶ Results for workflow nodes.
Returns: Results for workflow nodes. Return type: list
-
towerlib.entities.notification module¶
Main code for notification.
-
class
towerlib.entities.notification.
Notification
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the notifications of Ansible Tower/AWX.
-
error
¶ The error status for the notification.
Returns: The error Return type: string
-
notification_type
¶ The notification type for which the notification has been sent.
Returns: The notification type Return type: string
-
notifications_sent
¶ How many notifications have been sent.
Returns: Total notifications sent Return type: int
-
recipients
¶ The recipients to whom the notification has been sent.
Returns: List of recipients Return type: []string
-
status
¶ The status of the notification.
Returns: The status of the application can be pending,successful,failed Return type: string
-
subject
¶ The subject of the notification.
Returns: The subject of the notification Return type: string
-
-
class
towerlib.entities.notification.
NotificationEmail
(data)[source]¶ Bases:
object
Notification type configuration for email.
-
host
¶ Host to where we send the email.
Returns: Host to where we send the email Return type: string
-
password
¶ The password to use.
Returns: Password Return type: string
-
port
¶ The port to where to send the email.
Returns: Port Return type: int
-
recipients
¶ Recipient list.
Returns: Recipient list Return type: []string
-
sender
¶ Sender email.
Returns: Sender Email Return type: string
-
timeout
¶ Timeout.
Returns: The timeout (defaults to 30) Return type: int
-
use_ssl
¶ Use SSL for the connection?
Returns: Use SSL for the connection Return type: bool
-
use_tls
¶ Use TLS for the connection?
Returns: Use TLS for the connection Return type: bool
-
username
¶ The username to use.
Returns: Username Return type: string
-
-
class
towerlib.entities.notification.
NotificationGrafana
(data)[source]¶ Bases:
object
Notification type configuration for WebHook.
-
grafana_key
¶ Get the grafana key.
Returns: The grafana key Return type: string
-
grafana_url
¶ The URL to call for the notification.
Returns: The URL to call for a notification Return type: string
-
-
class
towerlib.entities.notification.
NotificationHipChat
(data)[source]¶ Bases:
object
Notification type configuration for HipChat.
-
api_url
¶ //mycompany.hipchat.com).
Returns: API Url Return type: string Type: API Url (e.g Type: https
-
color
¶ Notification color.
Returns: Notification color Return type: string
-
message_from
¶ Label to be shown with notification.
Returns: Label to be shown with notification Return type: string
-
notify
¶ Notify room.
Returns: Notify room? Return type: bool
-
rooms
¶ Destination Rooms.
Returns: Destination Rooms Return type: []string
-
token
¶ The token.
Returns: token Return type: string
-
-
class
towerlib.entities.notification.
NotificationIRC
(data)[source]¶ Bases:
object
Notification type configuration for IRC.
-
nickname
¶ IRC Nick.
Returns: The irc nick Return type: string
-
password
¶ The IRC Server Password.
Returns: IRC Server Password Return type: string
-
port
¶ The IRC Server Port.
Returns: IRC Server Port Return type: int
-
server
¶ IRC Server Address.
Returns: The irc server address Return type: string
-
targets
¶ Destination channels or users.
Returns: Destination channels or users Return type: []string
-
use_ssl
¶ Use SSL for the connection?
Returns: Use SSL for the connection Return type: bool
-
-
class
towerlib.entities.notification.
NotificationMatterMost
(data)[source]¶ Bases:
object
Notification type configuration for MatterMost.
-
mattermost_no_verify_ssl
¶ Do not verify SSL on MatterMost.
Returns: Do we verify SSL? Return type: bool
-
mattermost_url
¶ The URL to call for the notification.
Returns: The URL to call for a notification Return type: string
-
-
class
towerlib.entities.notification.
NotificationPagerDuty
(data)[source]¶ Bases:
object
Notification type configuration for pagerduty.
-
client_name
¶ The client name for the PagerDuty.
Returns: The client name for PagerDuty Return type: string
-
service_key
¶ The service key for the PagerDuty.
Returns: The service key for PagerDuty Return type: string
-
subdomain
¶ Gets the pagerduty subdomain.
Returns: Pagerduty subdomain Return type: string
-
token
¶ The token for the PagerDuty.
Returns: The token for PagerDuty Return type: string
-
-
class
towerlib.entities.notification.
NotificationRocketChat
(data)[source]¶ Bases:
object
Notification type configuration for Rocket.Chat.
-
rocketchat_no_verify_ssl
¶ Do not verify SSL on Rocket.Chat.
Returns: Do we verify SSL? Return type: bool
-
rocketchat_url
¶ The URL to call for the notification.
Returns: The URL to call for a notification Return type: string
-
-
class
towerlib.entities.notification.
NotificationSlack
(data)[source]¶ Bases:
object
Notification type configuration for slack.
-
channels
¶ The channels to where we send the notification to.
Returns: List of channels to notify Return type: []string
-
token
¶ Token required to make an API call.
Returns: The token for the API call Return type: string
-
-
class
towerlib.entities.notification.
NotificationTemplate
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the notification template of Ansible Tower/AWX.
-
description
¶ The description of the notification template.
Returns: The description of the notification template Return type: string
-
name
¶ The name of the notification template.
Returns: The name of the notification template Return type: string
-
notification_configuration
¶ Gets the notification configuration.
Returns: The configuration for the notification Return type: dict
-
notification_type
¶ Notification type for the template.
Returns: Notification type for the template Return type: string
-
organization
¶ The Organization object that this project is part of.
Returns: The Organization object that this project is part of Return type: Organization
-
recent_notifications
¶ The groups configured in Tower/AWX.
Returns: The manager object for groups Return type: EntityManager
-
-
class
towerlib.entities.notification.
NotificationTwilio
(data)[source]¶ Bases:
object
Notification type configuration for twilio.
-
account_sid
¶ The account sid.
Returns: Account SID Return type: string
-
account_token
¶ Account Token.
Returns: Account Token Return type: string
-
from_number
¶ Source phone number.
Returns: The source phone number Return type: string
-
to_numbers
¶ Destination SMS numbers.
Returns: Destination SMS numbers Return type: []string
-
-
class
towerlib.entities.notification.
NotificationWebHook
(data)[source]¶ Bases:
object
Notification type configuration for WebHook.
-
disable_ssl_verification
¶ Disable SSL verification.
Returns: Do we verify SSL? Return type: bool
-
url
¶ The URL to call for the notification.
Returns: The URL to call for a notification Return type: string
-
towerlib.entities.organization module¶
Main code for organization.
-
class
towerlib.entities.organization.
Organization
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the organization entity of ansible tower.
-
DEFAULT_MEMBER_ROLE
= 'Member'¶
-
admins_count
¶ The number of administrators of the organization.
Returns: The count of the administrators on the organization. Return type: integer
-
create_inventory
(name, description, variables='{}')[source]¶ Creates an inventory.
Parameters: - name – The name of the inventory to create.
- description – The description of the inventory.
- variables – A json with the initial variables set on the inventory.
Returns: The created Inventory object on success, None otherwise.
Return type: Raises: InvalidVariables
– The variables provided as argument is not valid json.
-
create_inventory_script
(name, description, script)[source]¶ Creates a custom inventory script.
Parameters: - 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
(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 the organization.
Parameters: - 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 or ‘’ if None.
- 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: InvalidCredential
– The credential provided as argument does not exist.
-
create_team
(name, description)[source]¶ Creates a team.
Parameters: - name – The name of the team to create.
- description – The description of the team.
Returns: The created Team object on success, None otherwise.
Return type:
-
created_by
¶ The User that created the organization.
Returns: The user that created the organization in tower. Return type: User
-
credentials
¶ The credentials of the organization.
Returns: EntityManager of the credentials of the organization. Return type: EntityManager
-
custom_virtualenv
¶ The path of the custom virtual environment.
Returns: The path of the custom virtual environment. Return type: string
-
delete_inventory
(name)[source]¶ Deletes an inventory by name.
Parameters: 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_inventory_script
(name)[source]¶ Deletes a custom inventory script.
Parameters: name – The name of the custom inventory script to delete. Returns: True on success, False otherwise. Return type: bool Raises: InvalidInventoryScript
– The inventory_script provided as argument does not exist.
-
delete_project
(name)[source]¶ Deletes a project by username.
Parameters: 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
(name)[source]¶ Deletes a team by name.
Parameters: 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.
-
description
¶ The description of the Organization.
Returns: The description of the Organization. Return type: string
-
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_by_name
(name, credential_type)[source]¶ Retrieves credential matching a certain name.
Parameters: - name – The name of the credential to retrieve.
- credential_type – The type of credential.
Returns: A credential if found else none.
Return type: Raises: InvalidCredentialType
– The credential type given as a parameter was not found.
-
get_credential_by_name_with_type_id
(name, credential_type_id)[source]¶ Retrieves credential matching a certain name and the provided type by id.
Parameters: - name (str) – The name of the credential to retrieve.
- credential_type_id (int) – The type of credential.
Returns: A credential if found else none.
Return type:
-
get_inventory_by_name
(name)[source]¶ Retrieves an inventory.
Parameters: name – The name of the inventory to retrieve. Returns: inventory on success else None. Return type: inventory(Inventory)
-
get_inventory_script_by_name
(name)[source]¶ Retrieves an custom inventory script.
Parameters: name – The name of the custom inventory script to retrieve. Returns: custom inventory script on success else None. Return type: inventory(Inventory)
-
get_project_by_name
(name)[source]¶ Retrieves a project.
Parameters: name – The name of the project to retrieve. Returns: project on success else None. Return type: project (Project)
-
get_team_by_name
(name)[source]¶ Retrieves a team.
Parameters: name – The name of the team to retrieve. Returns: team on success else None. Return type: team (Team)
-
inventories
¶ The inventories of the organization.
Returns: EntityManager of the inventories of the organization. Return type: EntityManager
-
inventories_count
¶ The number of inventories of the organization.
Returns: The count of the inventories on the organization. Return type: integer
-
inventory_scripts
¶ The inventory scripts of the organization.
Returns: EntityManager of the inventory scripts of the organization. Return type: EntityManager
-
job_templates_count
¶ The number of job templates of the organization.
Returns: The count of the job templates on the organization. Return type: integer
-
modified_by
¶ The User that modified the organization last.
Returns: The user that modified the organization in tower last. Return type: User
-
name
¶ The name of the Organization.
Returns: The name of the organization. Return type: string
-
object_role_names
¶ The names of the object roles.
Returns: A list of strings for the object_roles. Return type: list
-
object_roles
¶ The object roles.
Returns: EntityManager of the roles supported. Return type: EntityManager
-
projects
¶ The projects of the organization.
Returns: EntityManager of the projects. Return type: EntityManager
-
projects_count
¶ The number of projects of the organization.
Returns: The count of the projects on the organization. Return type: integer
-
teams
¶ The teams of the organization.
Returns: EntityManager of the teams of the organization. Return type: EntityManager
-
teams_count
¶ The number of teams of the organization.
Returns: The count of the teams on the organization. Return type: integer
-
users
¶ The users of the organization.
Returns: EntityManager of the users of the organization. Return type: EntityManager
-
users_count
¶ The number of user of the organization.
Returns: The count of the users on the organization. Return type: integer
-
towerlib.entities.project module¶
Main code for project.
-
class
towerlib.entities.project.
Project
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the project entity of ansible tower.
-
created_by
¶ The person that created the project.
Returns: The person that created the project. Return type: dict
-
credential
¶ The Credential object associated with this project.
Returns: The Credential object of the project. Return type: Credential
-
custom_virtualenv
¶ The path of the custom virtual environment.
Returns: The path of the custom virtual environment. Return type: string
-
description
¶ The description of the Project.
Returns: The description of the Project. Return type: string
-
is_last_job_failed
¶ A flag of whether the last job run failed.
Returns: True if the job failed, False otherwise. Return type: bool
-
is_last_update_failed
¶ Flag on whether the last update failed or not.
Returns: True if last update has failed, False otherwise. Return type: bool
-
job_templates
¶ The job templates for the project entity.
Returns: list of all the job templates object for the project. Return type: job_templates (list)
-
last_job
¶ The last job run on the project.
Returns: The last job executed. Return type: dict
-
last_job_run
¶ The date and time of the last run job.
Returns: The datetime object of when the last job run. Return type: datetime
-
last_update
¶ The last update of the project.
Returns: The last update. Return type: dict
-
last_updated
¶ The date and time of the last update.
Returns: The datetime of the last update, None if not set. Return type: datetime
-
local_path
¶ The internal local path of the project.
Returns: The internal local path of the project. Return type: string
-
name
¶ The name of the project.
Returns: The name of the project. Return type: string
-
next_job_run
¶ Not sure what this does.
Returns: None.
-
object_role_names
¶ The names of the object roles.
Returns: A list of strings for the object_roles. Return type: list
-
object_roles
¶ The object roles.
Returns: EntityManager of the object roles supported. Return type: EntityManager
-
organization
¶ The Organization object that this project is part of.
Returns: The Organization object that this project is part of. Return type: Organization
-
playbooks
¶ The playbooks of the project.
Returns: A list of the project specified playbooks. Return type: list
-
project_updates
¶ Get all the job_events for host.
Returns: list of all the job events for the host. Return type: list
-
scm_branch
¶ The branch of the scm used.
Returns: The branch of the scm used. Return type: string
-
scm_clean
¶ A flag to clean the scm or not.
Returns: True if set, False otherwise. Return type: bool
-
scm_delete_on_next_update
¶ A flag on whether to delete the scm on the next update.
Returns: True if set, False otherwise. Return type: bool
-
scm_delete_on_update
¶ A flag to delete the scm on update.
Returns: True if set, False otherwise. Return type: bool
-
scm_revision
¶ The hash of the scm revision.
Returns: The hash of the scm revision. Return type: string
-
scm_type
¶ The type of the scm used.
Returns: The type of the scm used. Return type: string
-
scm_update_cache_timeout
¶ The cache timeout set for the scm.
Returns: The cache time out set. Return type: integer
-
scm_update_on_launch
¶ A flag on whether to update scm on launch.
Returns: True if set, False otherwise. Return type: bool
-
scm_url
¶ The url of the scm used.
Returns: The url of the scm used. Return type: string
-
status
¶ The status of the project.
Returns: The status of the project. Return type: string
-
timeout
¶ The timeout setting of the project.
Returns: The timeout setting of the project. Return type: integer
-
towerlib.entities.role module¶
Main code for role.
-
class
towerlib.entities.role.
ObjectRole
(tower_instance, data)[source]¶ Bases:
towerlib.entities.role.Role
Models the object role entity of ansible tower.
-
class
towerlib.entities.role.
Role
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the role entity of ansible tower.
-
description
¶ The description of the role.
Returns: The description of the role. Return type: string
-
name
¶ The name of the role.
Returns: The name of the role. Return type: string
-
projects
¶ The projects of the team.
Returns: EntityManager of the projects. Return type: EntityManager
-
summary_fields
¶ The summary fields of the role.
Returns: The summary fields of the role. Return type: Organization
-
teams
¶ The teams that have the role assigned.
Returns: EntityManager of the teams. Return type: EntityManager
-
users
¶ The users of the team.
Returns: EntityManager of the users. Return type: EntityManager
-
towerlib.entities.schedule module¶
Main code for Schedule.
-
class
towerlib.entities.schedule.
Schedule
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the schedule entity of ansible tower.
-
datetime_end
¶ The last occurrence of the schedule occurs before this time, aftewards the schedule expires.
Returns: The last occurrence of the schedule occurs before this time, aftewards the schedule expires. Return type: datetime
-
datetime_start
¶ The first occurrence of the schedule occurs on or after this time.
Returns: The first occurrence of the schedule occurs on or after this time. Return type: datetime
-
description
¶ The description of the schedule.
Returns: The description of the schedule. Return type: string
-
diff_mode
¶ Display mode for the execution the schedule.
Returns: Are we displaying diff mode for the run? Return type: boolean
-
enabled
¶ Enables processing of this schedule.
Returns: Enables processing of this schedule. Return type: bool
-
extra_data
¶ The extra data of the schedule.
Returns: The extra data of the schedule. Return type: dict
-
inventory
¶ The inventory this schedule belongs to.
Returns: The inventory this schedule belongs to. Return type: Inventory
The job tags of the schedule.
Returns: The job tags of the schedule. Return type: string
-
job_type
¶ The job_type of the schedule.
Returns: The job_type of the schedule. Return type: string
-
limit
¶ The limit of the schedule.
Returns: The limit of the schedule. Return type: string
-
name
¶ The name of the schedule.
Returns: The name of the schedule. Return type: string
-
next_run
¶ The next time that the scheduled action will run.
Returns: The next time that the scheduled action will run. Return type: datetime
-
recurrence_rule
¶ A value representing the schedules iCal recurrence rule.
Returns: A value representing the schedules iCal recurrence rule. Return type: string
-
scm_branch
¶ The scm_branch of the schedule.
Returns: The scm_branch of the schedule. Return type: string
The tags to skip of the schedule.
Returns: The tags to skip of the schedule. Return type: string
-
timezone
¶ The timezone of the schedule.
Returns: The timezone of the schedule. Return type: string
-
unified_job_template
¶ Unified job template.
Returns: Unified job template . Return type: JobTemplate
-
until
¶ Until when does the schedule run?
Returns: Until when does the schedule run? Return type: string
-
verbosity
¶ Verbosity of the run.
Returns: Verbosity of the run . Return type: string
-
towerlib.entities.settings module¶
Main code for settings.
-
class
towerlib.entities.settings.
Saml
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the saml entity of ansible tower.
-
callback_url
¶ The saml callback url.
Returns: The saml callback url. Return type: string
-
enabled_idps
¶ The configured IDPS as a dictionary.
Returns: The configured IDPS as a dictionary. Return type: string
-
extra_data
¶ The IDP attributes that are mapped to extra_attributes.
Returns: The IDP attributes that are mapped to extra_attributes. Return type: string
-
metadata_url
¶ The saml metadata url.
Returns: The saml metadata url. Return type: string
-
organization_attributes
¶ The saml callback url.
Returns: The saml callback url. Return type: string
-
organization_information
¶ The organization information url.
Returns: The organization information url. Return type: string
-
organization_map
¶ The mapping to organization admins/users from social auth accounts.
Returns: The mapping to organization admins/users from social auth accounts. Return type: string
-
security_config
¶ The saml security config.
Returns: The saml security config. Return type: string
-
sp_entity_id
¶ The application-defined unique identifier for SAML service provider (SP) configuration.
Returns: The application-defined unique identifier for SAML service provider (SP) configuration. Return type: string
-
sp_extra
¶ The Service Provider configuration setting.
Returns: The Service Provider configuration setting. Return type: string
-
sp_private_key
¶ The private key.
Returns: The private key. Return type: string
-
sp_public_cert
¶ The public certificate.
Returns: The public certificate. Return type: string
-
support_contact
¶ The support contact information.
Returns: The support contact information. Return type: string
-
team_attributes
¶ The translation of user team membership into Tower.
Returns: The translation of user team membership into Tower. Return type: string
-
team_map
¶ The mapping of team members (users) from social auth accounts.
Returns: The mapping of team members (users) from social auth accounts. Return type: string
-
technical_contact
¶ The technical contact information.
Returns: The technical contact information. Return type: string
-
url
¶ The url of the object.
Returns: The full url of the representation of the object in tower. Return type: string
-
towerlib.entities.team module¶
Main code for team.
-
class
towerlib.entities.team.
Team
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the team entity of ansible tower.
-
add_credential_permission_admin
(credential_name, credential_type)[source]¶ Adds a credential with admin permissions.
Parameters: - credential_name – The name of the credential to add.
- credential_type (str) – The type of the credential to use
Returns: True on success, False otherwise.
-
add_credential_permission_use
(credential_name, credential_type)[source]¶ Adds a credential with admin permissions.
Parameters: - credential_name – The name of the credential to add.
- credential_type (str) – The type of the credential to use
Returns: True on success, False otherwise.
-
add_inventory_permission_ad_hoc
(inventory_name)[source]¶ Adds an inventory with ad hoc permissions.
Parameters: inventory_name – The name of the inventory to add. Returns: True on success, False otherwise.
-
add_inventory_permission_admin
(inventory_name)[source]¶ Adds an inventory with admin permissions.
Parameters: inventory_name – The name of the inventory to add. Returns: True on success, False otherwise.
-
add_inventory_permission_update
(inventory_name)[source]¶ Adds an inventory with update permissions.
Parameters: inventory_name – The name of the inventory to add. Returns: True on success, False otherwise.
-
add_inventory_permission_use
(inventory_name)[source]¶ Adds an inventory with use permissions.
Parameters: inventory_name – The name of the inventory to add. Returns: True on success, False otherwise.
-
add_job_template_permission_admin
(job_template_name)[source]¶ Adds a job template with admin permissions.
Parameters: job_template_name – The name of the job template to add. Returns: True on success, False otherwise.
-
add_job_template_permission_execute
(job_template_name)[source]¶ Adds a job template with execute permissions.
Parameters: job_template_name – The name of the job template to add. Returns: True on success, False otherwise.
-
add_organization_role_by_name
(organization_name, role_name)[source]¶ Adds an organization role to the team.
Parameters: - organization_name (str) – The name of the organization to search roles for.
- role_name (str) – The name of the role to add.
Returns: True on success, False otherwise.
-
add_project_permission_admin
(project_name)[source]¶ Adds a project with admin permissions.
Parameters: project_name – The name of the project to add. Returns: True on success, False otherwise.
-
add_project_permission_update
(project_name)[source]¶ Adds a project with update permissions.
Parameters: project_name – The name of the project to add. Returns: True on success, False otherwise.
-
add_project_permission_use
(project_name)[source]¶ Adds a project with use permissions.
Parameters: project_name – The name of the project to add. Returns: True on success, False otherwise.
-
add_user_as_admin
(username)[source]¶ Adds a user as an admin of the team.
Parameters: username – The username of the user to add. Returns: True on success, False otherwise.
-
add_user_as_member
(username)[source]¶ Adds a user as a member of the team.
Parameters: username – The username of the user to add. Returns: True on success, False otherwise.
-
credentials
¶ The credentials of the team.
Returns: EntityManager of the credentials. Return type: EntityManager
-
description
¶ The description of the team.
Returns: The description of the team. Return type: string
-
get_user_by_username
(username)[source]¶ Retrieves a user of the team by its username.
Parameters: username – The username of the user to retrieve. Returns: user (User) on success, None otherwise.
-
name
¶ The name of the team.
Returns: The name of the team. Return type: string
-
object_role_names
¶ The names of the object roles.
Returns: A list of strings for the object_roles. Return type: list
-
object_roles
¶ The object roles.
Returns: EntityManager of the object roles supported. Return type: EntityManager
-
organization
¶ The Organization of the team.
Returns: The organization of the team. Return type: Organization
-
projects
¶ The projects of the team.
Returns: EntityManager of the projects. Return type: EntityManager
-
remove_credential_permission_admin
(credential_name, credential_type)[source]¶ Removes a credential with admin permissions.
Parameters: - credential_name – The name of the credential to remove.
- credential_type (str) – The type of the credential to use
Returns: True on success, False otherwise.
-
remove_credential_permission_use
(credential_name, credential_type)[source]¶ Removes a credential with use permissions.
Parameters: - credential_name – The name of the credential to remove.
- credential_type (str) – The type of the credential to use
Returns: True on success, False otherwise.
-
remove_inventory_permission_ad_hoc
(inventory_name)[source]¶ Removes an inventory with ad hoc permissions.
Parameters: inventory_name – The name of the inventory to remove. Returns: True on success, False otherwise.
-
remove_inventory_permission_admin
(inventory_name)[source]¶ Removes an inventory with admin permissions.
Parameters: inventory_name – The name of the inventory to remove. Returns: True on success, False otherwise.
-
remove_inventory_permission_update
(inventory_name)[source]¶ Removes an inventory with update permissions.
Parameters: inventory_name – The name of the inventory to remove. Returns: True on success, False otherwise.
-
remove_inventory_permission_use
(inventory_name)[source]¶ Removes an inventory with use permissions.
Parameters: inventory_name – The name of the inventory to remove. Returns: True on success, False otherwise.
-
remove_job_template_permission_admin
(job_template_name)[source]¶ Removes a job template with admin permissions.
Parameters: job_template_name – The name of the job template to remove. Returns: True on success, False otherwise.
-
remove_job_template_permission_execute
(job_template_name)[source]¶ Removes a job template with execute permissions.
Parameters: job_template_name – The name of the job template to remove. Returns: True on success, False otherwise.
-
remove_organization_role_by_name
(organization_name, role_name)[source]¶ Removes an organization role from the team.
Parameters: - organization_name (str) – The name of the organization to search roles for.
- role_name (str) – The name of the role to add.
Returns: True on success, False otherwise.
-
remove_project_permission_admin
(project_name)[source]¶ Removes a project with admin permissions.
Parameters: project_name – The name of the project to remove. Returns: True on success, False otherwise.
-
remove_project_permission_update
(project_name)[source]¶ Removes a project with update permissions.
Parameters: project_name – The name of the project to remove. Returns: True on success, False otherwise.
-
remove_project_permission_use
(project_name)[source]¶ Removes a project with use permissions.
Parameters: project_name – The name of the project to remove. Returns: True on success, False otherwise.
-
remove_user_as_admin
(username)[source]¶ Removes a user as an admin of the team.
Parameters: username – The username of the user to remove. Returns: True on success, False otherwise.
-
remove_user_as_member
(username)[source]¶ Removes a user as a member of the team.
Parameters: username – The username of the user to remove. Returns: True on success, False otherwise.
-
roles
¶ The roles.
Returns: EntityManager of the roles. Return type: EntityManager
-
users
¶ The users of the team.
Returns: EntityManager of the users. Return type: EntityManager
-
towerlib.entities.user module¶
Main code for user.
-
class
towerlib.entities.user.
User
(tower_instance, data)[source]¶ Bases:
towerlib.entities.core.Entity
Models the user entity of ansible tower.
-
associate_with_organization_role
(organization, role)[source]¶ Associate a user to an organizational role.
Parameters: - organization – The organization that we want to assign to
- role – The role we want to assign to the object
Returns: If it managed to associate the user to the organization
Return type: bool
-
auth
¶ The authentication setting for the user.
Returns: Used authentication methods set for the user. Return type: list
-
credentials
¶ The credentials that the user has.
Returns: EntityManager of the credentials. Return type: EntityManager
-
disassociate_from_organization_role
(organization, role)[source]¶ Disassociate a user to an organizational role.
Parameters: - organization – The organization object that we want to assign to
- role – The role we want to assign to the object
Returns: If it managed to disassociate the user to the organization
Return type: bool
-
email
¶ The email of the user.
Returns: The email of the user. Return type: string
-
external_account
¶ The external account entry for the user.
Returns: The external account entry for the user if it exists. None: If no entry exists. Return type: string
-
first_name
¶ The first name of the user.
Returns: The first name of the user. Return type: string
-
is_superuser
¶ The superuser status of the user.
Returns: True if the user is a superuser, False otherwise. Return type: bool
-
is_system_auditor
¶ The system auditor status of the user.
Returns: True if the user is a system auditor, False otherwise. Return type: bool
-
last_login
¶ The last time the user logged in to the system.
Returns: The datetime object of the date and time of the last login for the user. None: If there is no entry for the last login date. Return type: datetime
-
last_name
¶ The last name of the user.
Returns: The last name of the user. Return type: string
-
ldap_dn
¶ The ldap dn setting for the user.
Returns: The ldap dn entry for the user. Return type: string
-
organizations
¶ The organizations that the user is part of.
Returns: EntityManager of the organizations. Return type: EntityManager
-
password
¶ The password of the user.
Returns: The masked password value of the user. Return type: string
-
projects
¶ The projects that the user is part of.
Returns: EntityManager of the projects. Return type: EntityManager
-
roles
¶ The roles that the user has.
Returns: EntityManager of the roles. Return type: EntityManager
-
teams
¶ The teams that the user is part of.
Returns: EntityManager of the teams. Return type: EntityManager
-
username
¶ The username of the user.
Returns: The username of the user. Return type: string
-