ansible.module_utils package

Submodules

ansible.module_utils.a10 module

ansible.module_utils.a10.a10_argument_spec()[source]
ansible.module_utils.a10.axapi_failure(result)[source]
ansible.module_utils.a10.axapi_call(module, url, post=None)[source]

Returns a datastructure based on the result of the API call

ansible.module_utils.a10.axapi_authenticate(module, base_url, username, password)[source]
ansible.module_utils.a10.axapi_enabled_disabled(flag)[source]

The axapi uses 0/1 integer values for flags, rather than strings or booleans, so convert the given flag to a 0 or 1. For now, params are specified as strings only so thats what we check.

ansible.module_utils.a10.axapi_get_port_protocol(protocol)[source]
ansible.module_utils.a10.axapi_get_vport_protocol(protocol)[source]

ansible.module_utils.api module

This module adds shared support for generic api modules.

In order to use this module, include it as part of a custom module as shown below.

** Note: The order of the import statements does matter. **

from ansible.module_utils.basic import *
from ansible.module_utils.api import *

The ‘api’ module provides the following common argument specs:

  • rate limit spec

    • rate: number of requests per time unit (int)
    • rate_limit: time window in which the limit is applied in seconds
  • retry spec

    • retries: number of attempts
    • retry_pause: delay between attempts in seconds
ansible.module_utils.api.rate_limit_argument_spec(spec=None)[source]

Creates an argument spec for working with rate limiting

ansible.module_utils.api.retry_argument_spec(spec=None)[source]

Creates an argument spec for working with retrying

ansible.module_utils.api.basic_auth_argument_spec(spec=None)[source]
ansible.module_utils.api.rate_limit(rate=None, rate_limit=None)[source]

rate limiting decorator

ansible.module_utils.api.retry(retries=None, retry_pause=1)[source]

Retry decorator

ansible.module_utils.azure_rm_common module

ansible.module_utils.azure_rm_common.azure_id_to_dict(id)[source]
class ansible.module_utils.azure_rm_common.AzureRMModuleBase(derived_arg_spec, bypass_checks=False, no_log=False, check_invalid_arguments=True, mutually_exclusive=None, required_together=None, required_one_of=None, add_file_common_args=False, supports_check_mode=False, required_if=None, supports_tags=True, facts_module=False)[source]

Bases: object

exec_module(**kwargs)[source]
fail(msg, **kwargs)[source]

Shortcut for calling module.fail()

Parameters:
  • msg – Error message text.
  • kwargs – Any key=value pairs
Returns:

None

log(msg, pretty_print=False)[source]
validate_tags(tags)[source]

Check if tags dictionary contains string:string pairs.

Parameters:tags – dictionary of string:string pairs
Returns:None
update_tags(tags)[source]

Call from the module to update metadata tags. Returns tuple with bool indicating if there was a change and dict of new tags to assign to the object.

Parameters:tags – metadata tags from the object
Returns:bool, dict
has_tags(obj_tags, tag_list)[source]

Used in fact modules to compare object tags to list of parameter tags. Return true if list of parameter tags exists in object tags.

Parameters:
  • obj_tags – dictionary of tags from an Azure object.
  • tag_list – list of tag keys or tag key:value pairs
Returns:

bool

get_resource_group(resource_group)[source]

Fetch a resource group.

Parameters:resource_group – name of a resource group
Returns:resource group object
serialize_obj(obj, class_name)[source]

Return a JSON representation of an Azure object.

Parameters:
  • obj – Azure object
  • class_name – Name of the object’s class
Returns:

serialized result

get_poller_result(poller, wait=5)[source]

Consistent method of waiting on and retrieving results from Azure’s long poller.

Parameters:
  • poller – Azure poller object
  • wait (integer) – How long to wait.
Returns:

object resulting from the original request

check_provisioning_state(azure_object, requested_state='present')[source]

Check an Azure object’s provisioning state.

If something did not complete the provisioning process, then we cannot operate on it.

Parameters:azure_object – An object such as a subnet, storageaccount, etc. Must have provisioning_state and name attributes.

:return None

get_blob_client(resource_group_name, storage_account_name)[source]
create_default_pip(resource_group, location, name, allocation_method='Dynamic')[source]

Create a default public IP address <name>01 to associate with a network interface. If a PIP address matching <vm name>01 exists, return it. Otherwise, create one.

Parameters:
  • resource_group – name of an existing resource group
  • location – a valid azure location
  • name – base name to assign the public IP address
  • allocation_method – one of ‘Static’ or ‘Dynamic’
Returns:

PIP object

create_default_securitygroup(resource_group, location, name, os_type, open_ports)[source]

Create a default security group :name: to associate with a network interface.

If a security group matching :name: exists, return it. Otherwise, create one.

Parameters:
  • resource_group – Resource group name
  • location – azure location name
  • name – base name to use for the security group
  • os_type – one of ‘Windows’ or ‘Linux’. Determins any default rules added to the security group.
  • open_ports (list of integers) – list of network ports to open
Returns:

security_group object

storage_client
network_client
rm_client
compute_client

ansible.module_utils.basic module

ansible.module_utils.basic.iteritems(d)[source]
ansible.module_utils.basic.get_platform()[source]

Get the systems platform or OS name.

For example: ‘Linux’, ‘Windows’ or ‘Java’.

Returns:The name of the platform as a string. An empty string is returned if the value cannot be determined.
ansible.module_utils.basic.get_distribution()[source]

Get the systems distribution name if applicable.

Possible results include: ‘Amazon’, ‘SuSE’, ‘UnitedLinux’, ‘arch’, ‘centos’, ‘debian’, ‘fedora’, ‘gentoo’, ‘mandrake’, ‘mandriva’, ‘redhat’, ‘rocks’, ‘slackware’, ‘turbolinux’, ‘yellowdog’, ‘OtherLinux’

Returns:The name of the distribution as a string. If system is linux, but no known distribution is detected ‘OtherLinux’ is returned.
ansible.module_utils.basic.get_distribution_version()[source]

Get the linux distribution version, if applicable.

Returns:A string or None. If the system is linux, the distribution version number is returned as a string. If system is not linux, None is returned.
ansible.module_utils.basic.get_all_subclasses(cls)[source]

Get a list of all class objects that subclass :cls:.

Used by modules like :Hardware: or :Network: fact classes to retrieve all subclasses of a given class. __subclasses__() only returns direct subclasses. get_all_subclasses() goes down into the class tree.

Returns:class: objects.
Return type:A list of
ansible.module_utils.basic.load_platform_subclass(cls, *args, **kwargs)[source]

used by modules like User to have different implementations based on detected platform. See User module for an example.

ansible.module_utils.basic.json_dict_unicode_to_bytes(d, encoding='utf-8')[source]

Recursively convert dict keys and values to byte str

Specialized for json return because this only handles, lists, tuples, and dict container types (the containers that the json module returns)

ansible.module_utils.basic.json_dict_bytes_to_unicode(d, encoding='utf-8')[source]

Recursively convert dict keys and values to byte str

Specialized for json return because this only handles, lists, tuples, and dict container types (the containers that the json module returns)

ansible.module_utils.basic.return_values(obj)[source]

Return stringified values from datastructures. For use with removing sensitive values pre-jsonification.

ansible.module_utils.basic.remove_values(value, no_log_strings)[source]

Remove strings in no_log_strings from value. If value is a container type, then remove a lot more

ansible.module_utils.basic.heuristic_log_sanitize(data, no_log_values=None)[source]

Remove strings that look like passwords from log messages

ansible.module_utils.basic.is_executable(path)[source]

Determine if the given :path: is executable.

Limitations:

* Does not account for FSACLs.
* Most times we really want to know "Can the current user execute this
  file"  This function does not tell us that, only if an execute bit is set.
ansible.module_utils.basic.env_fallback(*args, **kwargs)[source]

Load value from environment

exception ansible.module_utils.basic.AnsibleFallbackNotFound[source]

Bases: exceptions.Exception

class ansible.module_utils.basic.AnsibleModule(argument_spec, bypass_checks=False, no_log=False, check_invalid_arguments=True, mutually_exclusive=None, required_together=None, required_one_of=None, add_file_common_args=False, supports_check_mode=False, required_if=None)[source]

Bases: object

load_file_common_arguments(params)[source]

many modules deal with files, this encapsulates common options that the file module accepts such that it is directly available to all modules and they can share code.

selinux_mls_enabled()[source]
selinux_enabled()[source]
selinux_initial_context()[source]
selinux_default_context(path, mode=0)[source]
selinux_context(path)[source]
user_and_group(filename)[source]
find_mount_point(path)[source]
is_special_selinux_path(path)[source]

Returns a tuple containing (True, selinux_context) if the given path is on a NFS or other ‘special’ fs mount point, otherwise the return will be (False, None).

set_default_selinux_context(path, changed)[source]
set_context_if_different(path, context, changed, diff=None)[source]
set_owner_if_different(path, owner, changed, diff=None)[source]
set_group_if_different(path, group, changed, diff=None)[source]
set_mode_if_different(path, mode, changed, diff=None)[source]
set_fs_attributes_if_different(file_args, changed, diff=None)[source]
set_directory_attributes_if_different(file_args, changed, diff=None)[source]
set_file_attributes_if_different(file_args, changed, diff=None)[source]
add_path_info(kwargs)[source]

for results that are files, supplement the info about the file in the return path with stats about the file path.

safe_eval(str, locals=None, include_exceptions=False)[source]
debug(msg)[source]
log(msg, log_args=None)[source]
get_bin_path(arg, required=False, opt_dirs=[])[source]

Find system executable in PATH.

Arg:
required (bool): if executable is not found and required is true, :fail_json: opt_dirs (list): optional list of directories to search in addition to PATH
Returns:arg: is found return full path; otherwise return None.
Return type:if
boolean(arg)[source]

return a bool for the arg

jsonify(data)[source]
from_json(data)[source]
add_cleanup_file(path)[source]
do_cleanup_files()[source]
exit_json(**kwargs)[source]

return from the module, without error

fail_json(**kwargs)[source]

return from the module, with an error message

fail_on_missing_params(required_params=None)[source]

This is for checking for required params when we can not check via argspec because we need more information than is simply given in the argspec.

digest_from_file(filename, algorithm)[source]

Return hex digest of local file for a digest_method specified by name, or None if file is not present.

md5(filename)[source]

Return MD5 hex digest of local file using digest_from_file().

Do not use this function unless you have no other choice for:
  1. Optional backwards compatibility
  2. Compatibility with a third party protocol

This function will not work on systems complying with FIPS-140-2.

Most uses of this function can use the module.sha1 function instead.

sha1(filename)[source]

Return SHA1 hex digest of local file using digest_from_file().

sha256(filename)[source]

Return SHA-256 hex digest of local file using digest_from_file().

backup_local(fn)[source]

make a date-marked backup of the specified file, return True or False on success or failure

cleanup(tmpfile)[source]
atomic_move(src, dest, unsafe_writes=False)[source]

atomically move src to dest, copying attributes from dest, returns true on success it uses os.rename to ensure this as it is an atomic operation, rest of the function is to work around limitations, corner cases and ensure selinux context is saved if possible

run_command(args, check_rc=False, close_fds=True, executable=None, data=None, binary_data=False, path_prefix=None, cwd=None, use_unsafe_shell=False, prompt_regex=None, environ_update=None)[source]

Execute a command, returns rc, stdout, and stderr.

Parameters:
  • args – is the command to run * If args is a list, the command will be run with shell=False. * If args is a string and use_unsafe_shell=False it will split args to a list and run with shell=False * If args is a string and use_unsafe_shell=True it runs with shell=True.
  • environ_update – dictionary to update os.environ with
Kw check_rc:

Whether to call fail_json in case of non zero RC. Default False

Kw close_fds:

See documentation for subprocess.Popen(). Default True

Kw executable:

See documentation for subprocess.Popen(). Default None

Kw data:

If given, information to write to the stdin of the command

Kw binary_data:

If False, append a newline to the data. Default False

Kw path_prefix:

If given, additional path to find the command in. This adds to the PATH environment vairable so helper commands in the same directory can also be found

Kw cwd:

iIf given, working directory to run the command inside

Kw use_unsafe_shell:
 

See args parameter. Default False

Kw prompt_regex:
 

Regex string (not a compiled regex) which can be used to detect prompts in the stdout which would otherwise cause the execution to hang (especially if no input data is specified)

append_to_file(filename, str)[source]
pretty_bytes(size)[source]
is_executable(path)

Determine if the given :path: is executable.

Limitations:

* Does not account for FSACLs.
* Most times we really want to know "Can the current user execute this
  file"  This function does not tell us that, only if an execute bit is set.
ansible.module_utils.basic.get_module_path()[source]

ansible.module_utils.cloudstack module

ansible.module_utils.cloudstack.cs_argument_spec()[source]
ansible.module_utils.cloudstack.cs_required_together()[source]
class ansible.module_utils.cloudstack.AnsibleCloudStack(module)[source]

Bases: object

get_or_fallback(key=None, fallback_key=None)[source]
has_changed(want_dict, current_dict, only_keys=None)[source]
get_vpc(key=None)[source]

Return a VPC dictionary or the value of given key of.

get_network(key=None)[source]

Return a network dictionary or the value of given key of.

get_project(key=None)[source]
get_ip_address(key=None)[source]
get_vm(key=None)[source]
get_zone(key=None)[source]
get_os_type(key=None)[source]
get_hypervisor()[source]
get_account(key=None)[source]
get_domain(key=None)[source]
get_tags(resource=None)[source]
ensure_tags(resource, resource_type=None)[source]
get_capabilities(key=None)[source]
poll_job(job=None, key=None)[source]
get_result(resource)[source]

ansible.module_utils.database module

exception ansible.module_utils.database.SQLParseError[source]

Bases: exceptions.Exception

exception ansible.module_utils.database.UnclosedQuoteError[source]

Bases: ansible.module_utils.database.SQLParseError

ansible.module_utils.database.pg_quote_identifier(identifier, id_type)[source]
ansible.module_utils.database.mysql_quote_identifier(identifier, id_type)[source]

ansible.module_utils.docker_common module

class ansible.module_utils.docker_common.Client(**kwargs)[source]

Bases: object

ansible.module_utils.docker_common.human_to_bytes(number)[source]
class ansible.module_utils.docker_common.DockerBaseClass[source]

Bases: object

log(msg, pretty_print=False)[source]
class ansible.module_utils.docker_common.AnsibleDockerClient(argument_spec=None, supports_check_mode=False, mutually_exclusive=None, required_together=None, required_if=None)[source]

Bases: ansible.module_utils.docker_common.Client

log(msg, pretty_print=False)[source]
fail(msg)[source]
auth_params
get_container(name=None)[source]

Lookup a container and return the inspection results.

find_image(name, tag)[source]

Lookup an image and return the inspection results.

pull_image(name, tag='latest')[source]

Pull an image

ansible.module_utils.ec2 module

exception ansible.module_utils.ec2.AnsibleAWSError[source]

Bases: exceptions.Exception

ansible.module_utils.ec2.boto3_conn(module, conn_type=None, resource=None, region=None, endpoint=None, **params)[source]
ansible.module_utils.ec2.aws_common_argument_spec()[source]
ansible.module_utils.ec2.ec2_argument_spec()[source]
ansible.module_utils.ec2.get_aws_connection_info(module, boto3=False)[source]
ansible.module_utils.ec2.get_ec2_creds(module)[source]

for compatibility mode with old modules that don’t/can’t yet use ec2_connect method

ansible.module_utils.ec2.boto_fix_security_token_in_profile(conn, profile_name)[source]

monkey patch for boto issue boto/boto#2100

ansible.module_utils.ec2.connect_to_aws(aws_module, region, **params)[source]
ansible.module_utils.ec2.ec2_connect(module)[source]

Return an ec2 connection

ansible.module_utils.ec2.paging(pause=0, marker_property='marker')[source]

Adds paging to boto retrieval functions that support a ‘marker’ this is configurable as not all boto functions seem to use the same name.

ansible.module_utils.ec2.camel_dict_to_snake_dict(camel_dict)[source]
ansible.module_utils.ec2.ansible_dict_to_boto3_filter_list(filters_dict)[source]

Convert :filters_dict: (an Ansible dict of filters) to a list of dicts that :boto3: can use.

Parameters:filters_dict (dict) – Dict of AWS filters.

Basic Usage:

>>> filters = {'some-aws-id', 'i-01234567'}
>>> ansible_dict_to_boto3_filter_list(filters)
{
    'some-aws-id': 'i-01234567'
}
Returns:List of AWS filters and their values
[
{
‘Name’: ‘some-aws-id’, ‘Values’: [
‘i-01234567’,

]

}

]

Return type:List
ansible.module_utils.ec2.boto3_tag_list_to_ansible_dict(tags_list)[source]

Convert a boto3 list of resource tags to a flat dict of key:value pairs :param tags_list: List of dicts representing AWS tags. :type tags_list: list

Basic Usage:
>>> tags_list = [{'Key': 'MyTagKey', 'Value': 'MyTagValue'}]
>>> boto3_tag_list_to_ansible_dict(tags_list)
[
    {
        'Key': 'MyTagKey',
        'Value': 'MyTagValue'
    }
]
Returns:
Dict of key:value pairs representing AWS tags
{
‘MyTagKey’: ‘MyTagValue’,

}

Return type:Dict
ansible.module_utils.ec2.ansible_dict_to_boto3_tag_list(tags_dict)[source]

Convert a flat dict of key:value pairs representing AWS resource tags to a boto3 list of dicts :param tags_dict: Dict representing AWS resource tags. :type tags_dict: dict

Basic Usage:
>>> tags_dict = {'MyTagKey': 'MyTagValue'}
>>> ansible_dict_to_boto3_tag_list(tags_dict)
{
    'MyTagKey': 'MyTagValue'
}
Returns:List of dicts containing tag keys and values [
{
‘Key’: ‘MyTagKey’, ‘Value’: ‘MyTagValue’

}

]

Return type:List
ansible.module_utils.ec2.get_ec2_security_group_ids_from_names(sec_group_list, ec2_connection, vpc_id=None, boto3=True)[source]

Return list of security group IDs from security group names. Note that security group names are not unique across VPCs. If a name exists across multiple VPCs and no VPC ID is supplied, all matching IDs will be returned. This will probably lead to a boto exception if you attempt to assign both IDs to a resource so ensure you wrap the call in a try block

ansible.module_utils.eos module

ansible.module_utils.eos.to_list(val)[source]
class ansible.module_utils.eos.Eapi(module)[source]

Bases: object

connect()[source]
authorize()[source]
send(commands, encoding='json')[source]

Send commands to the device.

class ansible.module_utils.eos.Cli(module)[source]

Bases: object

connect(**kwargs)[source]
authorize()[source]
send(commands)[source]
class ansible.module_utils.eos.NetworkModule(*args, **kwargs)[source]

Bases: ansible.module_utils.basic.AnsibleModule

connected
config
connect()[source]
configure(commands, replace=False)[source]
config_terminal(commands)[source]
config_replace(commands)[source]
execute(commands, **kwargs)[source]
disconnect()[source]
parse_config(cfg)[source]
get_config()[source]
ansible.module_utils.eos.get_module(**kwargs)[source]

Return instance of NetworkModule

ansible.module_utils.f5 module

ansible.module_utils.f5.f5_argument_spec()[source]
ansible.module_utils.f5.f5_parse_arguments(module)[source]
ansible.module_utils.f5.bigip_api(bigip, user, password, validate_certs, port=443)[source]
ansible.module_utils.f5.fq_name(partition, name)[source]
ansible.module_utils.f5.fq_list_names(partition, list_names)[source]
exception ansible.module_utils.f5.F5ModuleError[source]

Bases: exceptions.Exception

ansible.module_utils.facts module

ansible.module_utils.facts.iteritems(d)[source]
exception ansible.module_utils.facts.TimeoutError[source]

Bases: exceptions.Exception

ansible.module_utils.facts.timeout(seconds=10, error_message='Timer expired')[source]
class ansible.module_utils.facts.Facts(module, load_on_init=True, cached_facts=None)[source]

Bases: object

This class should only attempt to populate those facts that are mostly generic to all systems. This includes platform facts, service facts (e.g. ssh keys or selinux), and distribution facts. Anything that requires extensive code or may have more than one possible implementation to establish facts for a given topic should subclass Facts.

SELINUX_MODE_DICT = {0: 'permissive', 1: 'enforcing', -1: 'disabled'}
PKG_MGRS = [{'path': '/usr/bin/yum', 'name': 'yum'}, {'path': '/usr/bin/dnf', 'name': 'dnf'}, {'path': '/usr/bin/apt-get', 'name': 'apt'}, {'path': '/usr/bin/zypper', 'name': 'zypper'}, {'path': '/usr/sbin/urpmi', 'name': 'urpmi'}, {'path': '/usr/bin/pacman', 'name': 'pacman'}, {'path': '/bin/opkg', 'name': 'opkg'}, {'path': '/usr/pkg/bin/pkgin', 'name': 'pkgin'}, {'path': '/opt/local/bin/pkgin', 'name': 'pkgin'}, {'path': '/opt/local/bin/port', 'name': 'macports'}, {'path': '/usr/local/bin/brew', 'name': 'homebrew'}, {'path': '/sbin/apk', 'name': 'apk'}, {'path': '/usr/sbin/pkg', 'name': 'pkgng'}, {'path': '/usr/sbin/swlist', 'name': 'SD-UX'}, {'path': '/usr/bin/emerge', 'name': 'portage'}, {'path': '/usr/sbin/pkgadd', 'name': 'svr4pkg'}, {'path': '/usr/bin/pkg', 'name': 'pkg'}, {'path': '/usr/bin/xbps-install', 'name': 'xbps'}, {'path': '/usr/local/sbin/pkg', 'name': 'pkgng'}]
populate()[source]
get_platform_facts()[source]
get_local_facts()[source]
get_cmdline()[source]
get_public_ssh_host_keys()[source]
get_pkg_mgr_facts()[source]
get_service_mgr_facts()[source]
get_lsb_facts()[source]
get_selinux_facts()[source]
get_caps_facts()[source]
get_fips_facts()[source]
get_date_time_facts()[source]
is_systemd_managed()[source]
get_user_facts()[source]
get_env_facts()[source]
get_dns_facts()[source]
get_python_facts()[source]
class ansible.module_utils.facts.Distribution(module)[source]

Bases: object

This subclass of Facts fills the distribution, distribution_version and distribution_release variables

To do so it checks the existance and content of typical files in /etc containing distribution information

This is unit tested. Please extend the tests to cover all distributions if you have them available.

OSDIST_LIST = ({'path': '/etc/oracle-release', 'name': 'OracleLinux'}, {'path': '/etc/slackware-version', 'name': 'Slackware'}, {'path': '/etc/redhat-release', 'name': 'RedHat'}, {'path': '/etc/vmware-release', 'allowempty': True, 'name': 'VMwareESX'}, {'path': '/etc/openwrt_release', 'name': 'OpenWrt'}, {'path': '/etc/system-release', 'name': 'Amazon'}, {'path': '/etc/alpine-release', 'name': 'Alpine'}, {'path': '/etc/release', 'name': 'Solaris'}, {'path': '/etc/arch-release', 'allowempty': True, 'name': 'Archlinux'}, {'path': '/etc/os-release', 'name': 'SuSE'}, {'path': '/etc/SuSE-release', 'name': 'SuSE'}, {'path': '/etc/gentoo-release', 'name': 'Gentoo'}, {'path': '/etc/os-release', 'name': 'Debian'}, {'path': '/etc/lsb-release', 'name': 'Mandriva'}, {'path': '/etc/altlinux-release', 'name': 'Altlinux'}, {'path': '/etc/os-release', 'name': 'NA'}, {'path': '/etc/coreos/update.conf', 'name': 'Coreos'})
SEARCH_STRING = {'Altlinux': 'ALT Linux', 'OracleLinux': 'Oracle Linux', 'RedHat': 'Red Hat'}
OS_FAMILY = {'Altlinux': 'Altlinux', 'AIX': 'AIX', 'MacOSX': 'Darwin', 'Archlinux': 'Archlinux', 'Slackware': 'Slackware', 'OracleLinux': 'RedHat', 'Fedora': 'RedHat', 'SuSE': 'Suse', 'Scientific': 'RedHat', 'Gentoo': 'Gentoo', 'OmniOS': 'Solaris', 'Funtoo': 'Gentoo', 'openSUSE_Leap': 'Suse', 'XenServer': 'RedHat', 'Amazon': 'RedHat', 'FreeBSD': 'FreeBSD', 'Mandrake': 'Mandrake', 'Raspbian': 'Debian', 'Debian': 'Debian', 'Alpine': 'Alpine', 'RedHat': 'RedHat', 'Manjaro': 'Archlinux', 'PSBM': 'RedHat', 'CloudLinux': 'RedHat', 'Ubuntu': 'Debian', 'SmartOS': 'Solaris', 'openSUSE': 'Suse', 'SLED': 'Suse', 'Mandriva': 'Mandrake', 'SLES': 'Suse', 'Nexenta': 'Solaris', 'SLC': 'RedHat', 'Ascendos': 'RedHat', 'OVS': 'RedHat', 'Solaris': 'Solaris', 'CentOS': 'RedHat', 'OpenIndiana': 'Solaris', 'OEL': 'RedHat', 'SLES_SAP': 'Suse', 'HPUX': 'HP-UX'}
populate()[source]
get_distribution_facts()[source]
get_distribution_AIX()[source]
get_distribution_HPUX()[source]
get_distribution_Darwin()[source]
get_distribution_FreeBSD()[source]
get_distribution_OpenBSD()[source]
get_distribution_Slackware(name, data, path)[source]
get_distribution_Amazon(name, data, path)[source]
get_distribution_OpenWrt(name, data, path)[source]
get_distribution_Alpine(name, data, path)[source]
get_distribution_Solaris(name, data, path)[source]
get_distribution_SuSE(name, data, path)[source]
get_distribution_Debian(name, data, path)[source]
get_distribution_Mandriva(name, data, path)[source]
get_distribution_NA(name, data, path)[source]
get_distribution_Coreos(name, data, path)[source]
class ansible.module_utils.facts.Hardware(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Facts

This is a generic Hardware subclass of Facts. This should be further subclassed to implement per platform. If you subclass this, it should define: - memfree_mb - memtotal_mb - swapfree_mb - swaptotal_mb - processor (a list) - processor_cores - processor_count

All subclasses MUST define platform.

platform = 'Generic'
populate()[source]
class ansible.module_utils.facts.LinuxHardware(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Hardware

Linux-specific subclass of Hardware. Defines memory and CPU facts: - memfree_mb - memtotal_mb - swapfree_mb - swaptotal_mb - processor (a list) - processor_cores - processor_count

In addition, it also defines number of DMI facts and device facts.

platform = 'Linux'
ORIGINAL_MEMORY_FACTS = frozenset(['SwapTotal', 'MemFree', 'MemTotal', 'SwapFree'])
MEMORY_FACTS = frozenset(['MemTotal', 'SwapTotal', 'SwapCached', 'SwapFree', 'Cached', 'MemFree', 'Buffers'])
populate()[source]
get_memory_facts()[source]
get_cpu_facts()[source]
get_dmi_facts()[source]

learn dmi facts from system

Try /sys first for dmi related facts. If that is not available, fall back to dmidecode executable

get_mount_facts(*args, **kwargs)[source]
get_device_facts()[source]
get_uptime_facts()[source]
get_lvm_facts()[source]

Get LVM Facts if running as root and lvm utils are available

class ansible.module_utils.facts.SunOSHardware(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Hardware

In addition to the generic memory and cpu facts, this also sets swap_reserved_mb and swap_allocated_mb that is available from swap -s.

platform = 'SunOS'
populate()[source]
get_cpu_facts()[source]
get_memory_facts()[source]
get_mount_facts(*args, **kwargs)[source]
class ansible.module_utils.facts.OpenBSDHardware(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Hardware

OpenBSD-specific subclass of Hardware. Defines memory, CPU and device facts: - memfree_mb - memtotal_mb - swapfree_mb - swaptotal_mb - processor (a list) - processor_cores - processor_count - processor_speed - devices

platform = 'OpenBSD'
DMESG_BOOT = '/var/run/dmesg.boot'
populate()[source]
get_sysctl()[source]
get_mount_facts(*args, **kwargs)[source]
get_memory_facts()[source]
get_processor_facts()[source]
get_device_facts()[source]
class ansible.module_utils.facts.FreeBSDHardware(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Hardware

FreeBSD-specific subclass of Hardware. Defines memory and CPU facts: - memfree_mb - memtotal_mb - swapfree_mb - swaptotal_mb - processor (a list) - processor_cores - processor_count - devices

platform = 'FreeBSD'
DMESG_BOOT = '/var/run/dmesg.boot'
populate()[source]
get_cpu_facts()[source]
get_memory_facts()[source]
get_mount_facts(*args, **kwargs)[source]
get_device_facts()[source]
get_dmi_facts()[source]

learn dmi facts from system

Use dmidecode executable if available

class ansible.module_utils.facts.DragonFlyHardware(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.FreeBSDHardware

class ansible.module_utils.facts.NetBSDHardware(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Hardware

NetBSD-specific subclass of Hardware. Defines memory and CPU facts: - memfree_mb - memtotal_mb - swapfree_mb - swaptotal_mb - processor (a list) - processor_cores - processor_count - devices

platform = 'NetBSD'
MEMORY_FACTS = ['MemTotal', 'SwapTotal', 'MemFree', 'SwapFree']
populate()[source]
get_cpu_facts()[source]
get_memory_facts()[source]
get_mount_facts(*args, **kwargs)[source]
class ansible.module_utils.facts.AIX(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Hardware

AIX-specific subclass of Hardware. Defines memory and CPU facts: - memfree_mb - memtotal_mb - swapfree_mb - swaptotal_mb - processor (a list) - processor_cores - processor_count

platform = 'AIX'
populate()[source]
get_cpu_facts()[source]
get_memory_facts()[source]
get_dmi_facts()[source]
class ansible.module_utils.facts.HPUX(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Hardware

HP-UX-specific subclass of Hardware. Defines memory and CPU facts: - memfree_mb - memtotal_mb - swapfree_mb - swaptotal_mb - processor - processor_cores - processor_count - model - firmware

platform = 'HP-UX'
populate()[source]
get_cpu_facts()[source]
get_memory_facts()[source]
get_hw_facts()[source]
class ansible.module_utils.facts.Darwin(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Hardware

Darwin-specific subclass of Hardware. Defines memory and CPU facts: - processor - processor_cores - memtotal_mb - memfree_mb - model - osversion - osrevision

platform = 'Darwin'
populate()[source]
get_sysctl()[source]
get_system_profile()[source]
get_mac_facts()[source]
get_cpu_facts()[source]
get_memory_facts()[source]
class ansible.module_utils.facts.Network(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Facts

This is a generic Network subclass of Facts. This should be further subclassed to implement per platform. If you subclass this, you must define: - interfaces (a list of interface names) - interface_<name> dictionary of ipv4, ipv6, and mac address information.

All subclasses MUST define platform.

platform = 'Generic'
IPV6_SCOPE = {'10': 'host', '20': 'link', '50': 'site', '40': 'admin', '0': 'global', '80': 'organization'}
populate()[source]
class ansible.module_utils.facts.LinuxNetwork(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Network

This is a Linux-specific subclass of Network. It defines - interfaces (a list of interface names) - interface_<name> dictionary of ipv4, ipv6, and mac address information. - all_ipv4_addresses and all_ipv6_addresses: lists of all configured addresses. - ipv4_address and ipv6_address: the first non-local address for each family.

platform = 'Linux'
populate()[source]
get_default_interfaces(ip_path)[source]
get_interfaces_info(ip_path, default_ipv4, default_ipv6)[source]
class ansible.module_utils.facts.GenericBsdIfconfigNetwork(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Network

This is a generic BSD subclass of Network using the ifconfig command. It defines - interfaces (a list of interface names) - interface_<name> dictionary of ipv4, ipv6, and mac address information. - all_ipv4_addresses and all_ipv6_addresses: lists of all configured addresses. It currently does not define - default_ipv4 and default_ipv6 - type, mtu and network on interfaces

platform = 'Generic_BSD_Ifconfig'
populate()[source]
get_default_interfaces(route_path)[source]
get_interfaces_info(ifconfig_path, ifconfig_options='-a')[source]
parse_interface_line(words)[source]
parse_options_line(words, current_if, ips)[source]
parse_nd6_line(words, current_if, ips)[source]
parse_ether_line(words, current_if, ips)[source]
parse_media_line(words, current_if, ips)[source]
parse_status_line(words, current_if, ips)[source]
parse_lladdr_line(words, current_if, ips)[source]
parse_inet_line(words, current_if, ips)[source]
parse_inet6_line(words, current_if, ips)[source]
parse_unknown_line(words, current_if, ips)[source]
get_options(option_string)[source]
merge_default_interface(defaults, interfaces, ip_type)[source]
class ansible.module_utils.facts.HPUXNetwork(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Network

HP-UX-specifig subclass of Network. Defines networking facts: - default_interface - interfaces (a list of interface names) - interface_<name> dictionary of ipv4 address information.

platform = 'HP-UX'
populate()[source]
get_default_interfaces()[source]
get_interfaces_info()[source]
class ansible.module_utils.facts.DarwinNetwork(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.GenericBsdIfconfigNetwork

This is the Mac OS X/Darwin Network Class. It uses the GenericBsdIfconfigNetwork unchanged

platform = 'Darwin'
parse_media_line(words, current_if, ips)[source]
class ansible.module_utils.facts.FreeBSDNetwork(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.GenericBsdIfconfigNetwork

This is the FreeBSD Network Class. It uses the GenericBsdIfconfigNetwork unchanged.

platform = 'FreeBSD'
class ansible.module_utils.facts.DragonFlyNetwork(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.GenericBsdIfconfigNetwork

This is the DragonFly Network Class. It uses the GenericBsdIfconfigNetwork unchanged.

platform = 'DragonFly'
class ansible.module_utils.facts.AIXNetwork(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.GenericBsdIfconfigNetwork

This is the AIX Network Class. It uses the GenericBsdIfconfigNetwork unchanged.

platform = 'AIX'
get_default_interfaces(route_path)[source]
get_interfaces_info(ifconfig_path, ifconfig_options='-a')[source]
parse_interface_line(words)[source]
class ansible.module_utils.facts.OpenBSDNetwork(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.GenericBsdIfconfigNetwork

This is the OpenBSD Network Class. It uses the GenericBsdIfconfigNetwork.

platform = 'OpenBSD'
get_interfaces_info(ifconfig_path, ifconfig_options='-aA')[source]
parse_lladdr_line(words, current_if, ips)[source]
class ansible.module_utils.facts.SunOSNetwork(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.GenericBsdIfconfigNetwork

This is the SunOS Network Class. It uses the GenericBsdIfconfigNetwork.

Solaris can have different FLAGS and MTU for IPv4 and IPv6 on the same interface so these facts have been moved inside the ‘ipv4’ and ‘ipv6’ lists.

platform = 'SunOS'
get_interfaces_info(ifconfig_path)[source]
parse_interface_line(words, current_if, interfaces)[source]
parse_ether_line(words, current_if, ips)[source]
class ansible.module_utils.facts.Virtual(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Facts

This is a generic Virtual subclass of Facts. This should be further subclassed to implement per platform. If you subclass this, you should define: - virtualization_type - virtualization_role - container (e.g. solaris zones, freebsd jails, linux containers)

All subclasses MUST define platform.

populate()[source]
class ansible.module_utils.facts.LinuxVirtual(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Virtual

This is a Linux-specific subclass of Virtual. It defines - virtualization_type - virtualization_role

platform = 'Linux'
populate()[source]
get_virtual_facts()[source]
class ansible.module_utils.facts.FreeBSDVirtual(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Virtual

This is a FreeBSD-specific subclass of Virtual. It defines - virtualization_type - virtualization_role

platform = 'FreeBSD'
populate()[source]
get_virtual_facts()[source]
class ansible.module_utils.facts.DragonFlyVirtual(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.FreeBSDVirtual

class ansible.module_utils.facts.OpenBSDVirtual(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Virtual

This is a OpenBSD-specific subclass of Virtual. It defines - virtualization_type - virtualization_role

platform = 'OpenBSD'
populate()[source]
get_virtual_facts()[source]
class ansible.module_utils.facts.HPUXVirtual(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Virtual

This is a HP-UX specific subclass of Virtual. It defines - virtualization_type - virtualization_role

platform = 'HP-UX'
populate()[source]
get_virtual_facts()[source]
class ansible.module_utils.facts.SunOSVirtual(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Virtual

This is a SunOS-specific subclass of Virtual. It defines - virtualization_type - virtualization_role - container

platform = 'SunOS'
populate()[source]
get_virtual_facts()[source]
class ansible.module_utils.facts.Ohai(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Facts

This is a subclass of Facts for including information gathered from Ohai.

populate()[source]
run_ohai()[source]
class ansible.module_utils.facts.Facter(module, load_on_init=True, cached_facts=None)[source]

Bases: ansible.module_utils.facts.Facts

This is a subclass of Facts for including information gathered from Facter.

populate()[source]
run_facter()[source]
ansible.module_utils.facts.get_file_content(path, default=None, strip=True)[source]
ansible.module_utils.facts.get_file_lines(path)[source]

get list of lines from file

ansible.module_utils.facts.ansible_facts(module, gather_subset)[source]
ansible.module_utils.facts.get_all_facts(module)[source]

ansible.module_utils.gce module

ansible.module_utils.gce.gce_connect(module, provider=None)[source]

Return a Google Cloud Engine connection.

ansible.module_utils.gce.unexpected_error_msg(error)[source]

Create an error string based on passed in error.

ansible.module_utils.ios module

ansible.module_utils.ios.to_list(val)[source]
class ansible.module_utils.ios.Cli(module)[source]

Bases: object

connect(**kwargs)[source]
authorize()[source]
send(commands)[source]
class ansible.module_utils.ios.NetworkModule(*args, **kwargs)[source]

Bases: ansible.module_utils.basic.AnsibleModule

connected
config
connect()[source]
configure(commands)[source]
execute(commands, **kwargs)[source]
disconnect()[source]
parse_config(cfg)[source]
get_config()[source]
ansible.module_utils.ios.get_module(**kwargs)[source]

Return instance of NetworkModule

ansible.module_utils.iosxr module

ansible.module_utils.iosxr.to_list(val)[source]
class ansible.module_utils.iosxr.Cli(module)[source]

Bases: object

connect(**kwargs)[source]
send(commands)[source]
class ansible.module_utils.iosxr.NetworkModule(*args, **kwargs)[source]

Bases: ansible.module_utils.basic.AnsibleModule

connected
config
connect()[source]
configure(commands)[source]
execute(commands, **kwargs)[source]
disconnect()[source]
parse_config(cfg)[source]
get_config()[source]
ansible.module_utils.iosxr.get_module(**kwargs)[source]

Return instance of NetworkModule

ansible.module_utils.ismount module

ansible.module_utils.ismount.ismount(path)[source]

Test whether a path is a mount point clone of os.path.ismount (from cpython Lib/posixpath.py) fixed to solve https://github.com/ansible/ansible-modules-core/issues/2186 and workaround non-fixed http://bugs.python.org/issue2466 this should be rewritten as soon as python issue 2466 is fixed probably check for python version and use os.path.ismount if fixed

to remove replace in this file ismount( -> os.path.ismount( and remove this function

ansible.module_utils.junos module

ansible.module_utils.junos.to_list(val)[source]
ansible.module_utils.junos.xml_to_json(val)[source]
ansible.module_utils.junos.xml_to_string(val)[source]
class ansible.module_utils.junos.Cli(module)[source]

Bases: object

connect(**kwargs)[source]
run_commands(commands, **kwargs)[source]
configure(commands, **kwargs)[source]
disconnect()[source]
class ansible.module_utils.junos.Netconf(module)[source]

Bases: object

connect(**kwargs)[source]
run_commands(commands, **kwargs)[source]
unlock_config()[source]
lock_config()[source]
check_config()[source]
commit_config(comment=None, confirm=None)[source]
load_config(candidate, action='replace', comment=None, confirm=None, format='text', commit=True)[source]
rollback_config(identifier, commit=True, comment=None)[source]
disconnect()[source]
get_facts(refresh=True)[source]
get_config(config_format='text')[source]
rpc(name, format='xml', **kwargs)[source]
class ansible.module_utils.junos.NetworkModule(*args, **kwargs)[source]

Bases: ansible.module_utils.basic.AnsibleModule

connected
connect()[source]
load_config(commands, **kwargs)[source]
rollback_config(identifier, commit=True)[source]
run_commands(commands, **kwargs)[source]
disconnect()[source]
get_config(**kwargs)[source]
get_facts(**kwargs)[source]
ansible.module_utils.junos.get_module(**kwargs)[source]

Return instance of NetworkModule

ansible.module_utils.known_hosts module

ansible.module_utils.known_hosts.add_git_host_key(module, url, accept_hostkey=True, create_dir=True)[source]

idempotently add a git url hostkey

ansible.module_utils.known_hosts.is_ssh_url(url)[source]

check if url is ssh

ansible.module_utils.known_hosts.get_fqdn(repo_url)[source]

chop the hostname out of a url

ansible.module_utils.known_hosts.check_hostkey(module, fqdn)[source]
ansible.module_utils.known_hosts.not_in_host_file(self, host)[source]
ansible.module_utils.known_hosts.add_host_key(module, fqdn, key_type='rsa', create_dir=False)[source]

use ssh-keyscan to add the hostkey

ansible.module_utils.mysql module

ansible.module_utils.mysql.mysql_connect(module, login_user=None, login_password=None, config_file='', ssl_cert=None, ssl_key=None, ssl_ca=None, db=None, cursor_class=None, connect_timeout=30)[source]

ansible.module_utils.netcfg module

class ansible.module_utils.netcfg.ConfigLine(text)[source]

Bases: object

ansible.module_utils.netcfg.ignore_line(text, tokens=None)[source]
ansible.module_utils.netcfg.parse(lines, indent, comment_tokens=None)[source]
class ansible.module_utils.netcfg.NetworkConfig(indent=None, contents=None, device_os=None)[source]

Bases: object

items
load(contents)[source]
load_from_file(filename)[source]
get(path)[source]
search(regexp, path=None)[source]
findall(regexp)[source]
expand(obj, items)[source]
flatten(data, obj=None)[source]
get_object(path)[source]
get_children(path)[source]
difference(other, path=None, match='line', replace='line')[source]
add(lines, parents=None)[source]
class ansible.module_utils.netcfg.Conditional(conditional, encoding='json')[source]

Bases: object

Used in command modules to evaluate waitfor conditions

OPERATORS = {'le': ['le', '<='], 'contains': ['contains'], 'lt': ['lt', '<'], 'ge': ['ge', '>='], 'gt': ['gt', '>'], 'eq': ['eq', '=='], 'neq': ['neq', 'ne', '!=']}
func(oper)[source]
get_value(result)[source]
get_xml(result)[source]
get_json(result)[source]
number(value)[source]
eq(value)[source]
neq(value)[source]
gt(value)[source]
ge(value)[source]
lt(value)[source]
le(value)[source]
contains(value)[source]

ansible.module_utils.nxos module

ansible.module_utils.nxos.to_list(val)[source]
class ansible.module_utils.nxos.Nxapi(module)[source]

Bases: object

connect()[source]
send(commands, command_type='cli_show_ascii', encoding='json')[source]

Send commands to the device.

class ansible.module_utils.nxos.Cli(module)[source]

Bases: object

connect(**kwargs)[source]
send(commands, encoding='text')[source]
class ansible.module_utils.nxos.NetworkModule(*args, **kwargs)[source]

Bases: ansible.module_utils.basic.AnsibleModule

connected
config
connect()[source]
configure(commands)[source]
configure_cli(commands)[source]
execute(commands, **kwargs)[source]
disconnect()[source]
parse_config(cfg)[source]
get_config()[source]
ansible.module_utils.nxos.get_module(**kwargs)[source]

Return instance of NetworkModule

ansible.module_utils.openstack module

ansible.module_utils.openstack.openstack_argument_spec()[source]
ansible.module_utils.openstack.openstack_find_nova_addresses(addresses, ext_tag, key_name=None)[source]
ansible.module_utils.openstack.openstack_full_argument_spec(**kwargs)[source]
ansible.module_utils.openstack.openstack_module_kwargs(**kwargs)[source]

ansible.module_utils.openswitch module

ansible.module_utils.openswitch.to_list(val)[source]
ansible.module_utils.openswitch.get_opsidl()[source]
class ansible.module_utils.openswitch.Response(resp, hdrs)[source]

Bases: object

json
class ansible.module_utils.openswitch.Rest(module)[source]

Bases: object

connect()[source]
send(method, path, data=None, headers=None)[source]
get(path, data=None, headers=None)[source]
put(path, data=None, headers=None)[source]
post(path, data=None, headers=None)[source]
delete(path, data=None, headers=None)[source]
class ansible.module_utils.openswitch.Cli(module)[source]

Bases: object

connect(**kwargs)[source]
send(commands, encoding='text')[source]
class ansible.module_utils.openswitch.NetworkModule(*args, **kwargs)[source]

Bases: ansible.module_utils.basic.AnsibleModule

config
connect()[source]
configure(commands)[source]
execute(commands, **kwargs)[source]
disconnect()[source]
parse_config(cfg)[source]
get_config()[source]
ansible.module_utils.openswitch.get_module(**kwargs)[source]

Return instance of NetworkModule

ansible.module_utils.pycompat24 module

ansible.module_utils.pycompat24.get_exception()[source]

Get the current exception.

This code needs to work on Python 2.4 through 3.x, so we cannot use “except Exception, e:” (SyntaxError on Python 3.x) nor “except Exception as e:” (SyntaxError on Python 2.4-2.5). Instead we must use

except Exception:
    e = get_exception()

ansible.module_utils.rax module

ansible.module_utils.rax.rax_slugify(value)[source]

Prepend a key with rax_ and normalize the key name

ansible.module_utils.rax.rax_clb_node_to_dict(obj)[source]

Function to convert a CLB Node object to a dict

ansible.module_utils.rax.rax_to_dict(obj, obj_type='standard')[source]

Generic function to convert a pyrax object to a dict

obj_type values:
standard clb server
ansible.module_utils.rax.rax_find_bootable_volume(module, rax_module, server, exit=True)[source]

Find a servers bootable volume

ansible.module_utils.rax.rax_find_image(module, rax_module, image, exit=True)[source]

Find a server image by ID or Name

ansible.module_utils.rax.rax_find_volume(module, rax_module, name)[source]

Find a Block storage volume by ID or name

ansible.module_utils.rax.rax_find_network(module, rax_module, network)[source]

Find a cloud network by ID or name

ansible.module_utils.rax.rax_find_server(module, rax_module, server)[source]

Find a Cloud Server by ID or name

ansible.module_utils.rax.rax_find_loadbalancer(module, rax_module, loadbalancer)[source]

Find a Cloud Load Balancer by ID or name

ansible.module_utils.rax.rax_argument_spec()[source]

Return standard base dictionary used for the argument_spec argument in AnsibleModule

ansible.module_utils.rax.rax_required_together()[source]

Return the default list used for the required_together argument to AnsibleModule

ansible.module_utils.rax.setup_rax_module(module, rax_module, region_required=True)[source]

Set up pyrax in a standard way for all modules

ansible.module_utils.redhat module

class ansible.module_utils.redhat.RegistrationBase(module, username=None, password=None)[source]

Bases: object

configure()[source]
enable()[source]
register()[source]
unregister()[source]
unsubscribe()[source]
update_plugin_conf(plugin, enabled=True)[source]
subscribe(**kwargs)[source]
class ansible.module_utils.redhat.Rhsm(module, username=None, password=None)[source]

Bases: ansible.module_utils.redhat.RegistrationBase

enable()[source]

Enable the system to receive updates from subscription-manager. This involves updating affected yum plugins and removing any conflicting yum repositories.

configure(**kwargs)[source]

Configure the system as directed for registration with RHN :raises: * Exception - if error occurs while running command

is_registered

Determine whether the current system is registered to :RHSM:.

Returns:Boolean - whether the current system is currently registered to RHSM.
register(username, password, autosubscribe, activationkey)[source]

Register the current system to the configured :RHSM: server.

Raises:Exception - if error occurs while running command subscription-manager register
unsubscribe()[source]

Unsubscribe a system from all subscribed channels :raises: * Exception - if error occurs while running command

unregister()[source]

Unregister a currently registered system :raises: * Exception - if error occurs while running command

subscribe(regexp)[source]

Subscribe current system to available pools matching the specified regular expression :raises: * Exception - if error occurs while running command

class ansible.module_utils.redhat.RhsmPool(module, **kwargs)[source]

Bases: object

Convenience class for housing subscription information

subscribe()[source]
class ansible.module_utils.redhat.RhsmPools(module)[source]

Bases: object

This class is used for manipulating pools subscriptions with RHSM

filter(regexp='^$')[source]

Return a list of RhsmPools whose name matches the provided regular expression

ansible.module_utils.service module

class ansible.module_utils.service.Service(module)[source]

Bases: object

This is the generic Service manipulation class that is subclassed based on system.

A subclass should override the following methods:
  • action
  • enable
  • status
action()[source]
status()[source]
enable()[source]
execute_command(cmd, daemonize=False)[source]
check_ps()[source]
result(msg='')[source]
run()[source]
ansible.module_utils.service.service_shared_arg_spec()[source]

ansible.module_utils.shell module

ansible.module_utils.shell.to_list(val)[source]
exception ansible.module_utils.shell.ShellError(msg, command=None)[source]

Bases: exceptions.Exception

class ansible.module_utils.shell.Command(command, prompt=None, response=None)[source]

Bases: object

class ansible.module_utils.shell.Shell(prompts_re=None, errors_re=None, kickstart=True)[source]

Bases: object

open(host, port=22, username=None, password=None, timeout=10, key_filename=None, pkey=None, look_for_keys=None, allow_agent=False)[source]
strip(data)[source]
receive(cmd=None)[source]
send(commands)[source]
close()[source]
handle_input(resp, prompt, response)[source]
sanitize(cmd, resp)[source]
read(response)[source]

ansible.module_utils.splitter module

ansible.module_utils.splitter.split_args(args)[source]

Splits args on whitespace, but intelligently reassembles those that may have been split over a jinja2 block or quotes.

When used in a remote module, we won’t ever have to be concerned about jinja2 blocks, however this function is/will be used in the core portions as well before the args are templated.

example input: a=b c=”foo bar” example output: [‘a=b’, ‘c=”foo bar”’]

Basically this is a variation shlex that has some more intelligence for how Ansible needs to use it.

ansible.module_utils.splitter.is_quoted(data)[source]
ansible.module_utils.splitter.unquote(data)[source]

removes first and last quotes from a string, if the string starts and ends with the same quotes

ansible.module_utils.urls module

exception ansible.module_utils.urls.ConnectionError[source]

Bases: exceptions.Exception

Failed to connect to the server

exception ansible.module_utils.urls.ProxyError[source]

Bases: ansible.module_utils.urls.ConnectionError

Failure to connect because of a proxy

exception ansible.module_utils.urls.SSLValidationError[source]

Bases: ansible.module_utils.urls.ConnectionError

Failure to connect due to SSL validation failing

exception ansible.module_utils.urls.NoSSLError[source]

Bases: ansible.module_utils.urls.SSLValidationError

Needed to connect to an HTTPS url but no ssl library available to verify the certificate

class ansible.module_utils.urls.CustomHTTPSConnection(*args, **kwargs)[source]

Bases: httplib.HTTPSConnection

connect()[source]

Connect to a host on a given (SSL) port.

class ansible.module_utils.urls.CustomHTTPSHandler(debuglevel=0, context=None)[source]

Bases: urllib2.HTTPSHandler

https_open(req)[source]
https_request(request)
ansible.module_utils.urls.generic_urlparse(parts)[source]

Returns a dictionary of url parts as parsed by urlparse, but accounts for the fact that older versions of that library do not support named attributes (ie. .netloc)

class ansible.module_utils.urls.RequestWithMethod(url, method, data=None, headers=None)[source]

Bases: urllib2.Request

Workaround for using DELETE/PUT/etc with urllib2 Originally contained in library/net_infrastructure/dnsmadeeasy

get_method()[source]
ansible.module_utils.urls.RedirectHandlerFactory(follow_redirects=None, validate_certs=True)[source]

This is a class factory that closes over the value of follow_redirects so that the RedirectHandler class has access to that value without having to use globals, and potentially cause problems where open_url or fetch_url are used multiple times in a module.

ansible.module_utils.urls.build_ssl_validation_error(hostname, port, paths)[source]

Inteligently build out the SSLValidationError based on what support you have installed

class ansible.module_utils.urls.SSLValidationHandler(hostname, port)[source]

Bases: urllib2.BaseHandler

A custom handler class for SSL validation.

Based on: http://stackoverflow.com/questions/1087227/validate-ssl-certificates-with-python http://techknack.net/python-urllib2-handlers/

CONNECT_COMMAND = 'CONNECT %s:%s HTTP/1.0\r\nConnection: close\r\n'
get_ca_certs()[source]
validate_proxy_response(response, valid_codes=[200])[source]

make sure we get back a valid code from the proxy

detect_no_proxy(url)[source]

Detect if the ‘no_proxy’ environment variable is set and honor those locations.

http_request(req)[source]
https_request(req)
ansible.module_utils.urls.maybe_add_ssl_handler(url, validate_certs)[source]
ansible.module_utils.urls.open_url(url, data=None, headers=None, method=None, use_proxy=True, force=False, last_mod_time=None, timeout=10, validate_certs=True, url_username=None, url_password=None, http_agent=None, force_basic_auth=False, follow_redirects='urllib2')[source]

Fetches a file from an HTTP/FTP server using urllib2

Does not require the module environment

ansible.module_utils.urls.basic_auth_header(username, password)[source]
ansible.module_utils.urls.url_argument_spec()[source]

Creates an argument spec that can be used with any module that will be requesting content via urllib/urllib2

ansible.module_utils.urls.fetch_url(module, url, data=None, headers=None, method=None, use_proxy=True, force=False, last_mod_time=None, timeout=10)[source]

Fetches a file from an HTTP/FTP server using urllib2. Requires the module environment

ansible.module_utils.vca module

exception ansible.module_utils.vca.VcaError(msg, **kwargs)[source]

Bases: exceptions.Exception

ansible.module_utils.vca.vca_argument_spec()[source]
class ansible.module_utils.vca.VcaAnsibleModule(*args, **kwargs)[source]

Bases: ansible.module_utils.basic.AnsibleModule

vca
gateway
vdc
get_vapp(vapp_name)[source]
get_vm(vapp_name, vm_name)[source]
create_instance()[source]
login()[source]
login_vca()[source]
login_vchs()[source]
login_vcd()[source]
save_services_config(blocking=True)[source]
fail(msg, **kwargs)[source]
exit(**kwargs)[source]
ansible.module_utils.vca.serialize_instances(instance_list)[source]
ansible.module_utils.vca.vca_login(module)[source]

ansible.module_utils.vmware module

exception ansible.module_utils.vmware.TaskError[source]

Bases: exceptions.Exception

ansible.module_utils.vmware.wait_for_task(task)[source]
ansible.module_utils.vmware.find_dvspg_by_name(dv_switch, portgroup_name)[source]
ansible.module_utils.vmware.find_entity_child_by_path(content, entityRootFolder, path)[source]
ansible.module_utils.vmware.find_cluster_by_name_datacenter(datacenter, cluster_name)[source]
ansible.module_utils.vmware.find_cluster_by_name(content, cluster_name, datacenter=None)[source]
ansible.module_utils.vmware.find_datacenter_by_name(content, datacenter_name)[source]
ansible.module_utils.vmware.find_dvs_by_name(content, switch_name)[source]
ansible.module_utils.vmware.find_hostsystem_by_name(content, hostname)[source]
ansible.module_utils.vmware.find_vm_by_id(content, vm_id, vm_id_type='vm_name', datacenter=None, cluster=None)[source]

UUID is unique to a VM, every other id returns the first match.

ansible.module_utils.vmware.find_vm_by_name(content, vm_name, folder=None, recurse=True)[source]
ansible.module_utils.vmware.find_host_portgroup_by_name(host, portgroup_name)[source]
ansible.module_utils.vmware.vmware_argument_spec()[source]
ansible.module_utils.vmware.connect_to_api(module, disconnect_atexit=True)[source]
ansible.module_utils.vmware.get_all_objs(content, vimtype, folder=None, recurse=True)[source]