ansible.plugins.lookup package¶
- 
class 
ansible.plugins.lookup.LookupBase(loader=None, templar=None, **kwargs)[source]¶ Bases:
object- 
run(terms, variables=None, **kwargs)[source]¶ When the playbook specifies a lookup, this method is run. The arguments to the lookup become the arguments to this method. One additional keyword argument named
variablesis added to the method call. It contains the variables available to ansible at the time the lookup is templated. For instance:"{{ lookup('url', 'https://toshio.fedorapeople.org/one.txt', validate_certs=True) }}"- would end up calling the lookup plugin named url’s run method like this::
 - run([‘https://toshio.fedorapeople.org/one.txt‘], variables=available_variables, validate_certs=True)
 
Lookup plugins can be used within playbooks for looping. When this happens, the first argument is a list containing the terms. Lookup plugins can also be called from within playbooks to return their values into a variable or parameter. If the user passes a string in this case, it is converted into a list.
Errors encountered during execution should be returned by raising AnsibleError() with a message describing the error.
Any strings returned by this method that could ever contain non-ascii must be converted into python’s unicode type as the strings will be run through jinja2 which has this requirement. You can use:
from ansible.module_utils.unicode import to_unicode result_string = to_unicode(result_string)
- 
 
Submodules¶
ansible.plugins.lookup.cartesian module¶
- 
class 
ansible.plugins.lookup.cartesian.LookupModule(loader=None, templar=None, **kwargs)[source]¶ Bases:
ansible.plugins.lookup.LookupBaseCreate the cartesian product of lists [1, 2, 3], [a, b] -> [1, a], [1, b], [2, a], [2, b], [3, a], [3, b]
ansible.plugins.lookup.consul_kv module¶
ansible.plugins.lookup.credstash module¶
ansible.plugins.lookup.csvfile module¶
- 
class 
ansible.plugins.lookup.csvfile.CSVRecoder(f, encoding='utf-8')[source]¶ Bases:
objectIterator that reads an encoded stream and reencodes the input to UTF-8
ansible.plugins.lookup.dict module¶
ansible.plugins.lookup.dig module¶
- 
ansible.plugins.lookup.dig.make_rdata_dict(rdata)[source]¶ While the ‘dig’ lookup plugin supports anything which dnspython supports out of the box, the following supported_types list describes which DNS query types we can convert to a dict.
Note: adding support for RRSIG is hard work. :)
- 
class 
ansible.plugins.lookup.dig.LookupModule(loader=None, templar=None, **kwargs)[source]¶ Bases:
ansible.plugins.lookup.LookupBase- 
run(terms, variables=None, **kwargs)[source]¶ Terms contains a string with things to dig for.
The following formats are supported:
Example Note example.com # A record example.com qtype=A # same example.com/TXT # specific qtype example.com qtype=txt # same 192.168.1.2/PTR - # reverse PTR
 - shortcut for 2.1.168.192.in-addr.arpa/PTR
 
example.net/AAAA @nameserver - # query specified server
 - can be comma-sep list of names/addresses
 
... flat=0 # returns a dict; default is 1 == string 
- 
 
ansible.plugins.lookup.dnstxt module¶
ansible.plugins.lookup.env module¶
ansible.plugins.lookup.etcd module¶
- 
class 
ansible.plugins.lookup.etcd.Etcd(url='http://127.0.0.1:4001', version='v1', validate_certs=True)[source]¶ Bases:
object
ansible.plugins.lookup.file module¶
ansible.plugins.lookup.fileglob module¶
ansible.plugins.lookup.first_found module¶
ansible.plugins.lookup.flattened module¶
ansible.plugins.lookup.hashi_vault module¶
ansible.plugins.lookup.indexed_items module¶
ansible.plugins.lookup.ini module¶
ansible.plugins.lookup.inventory_hostnames module¶
ansible.plugins.lookup.items module¶
ansible.plugins.lookup.lines module¶
ansible.plugins.lookup.list module¶
ansible.plugins.lookup.nested module¶
ansible.plugins.lookup.password module¶
- 
class 
ansible.plugins.lookup.password.LookupModule(loader=None, templar=None, **kwargs)[source]¶ 
ansible.plugins.lookup.pipe module¶
ansible.plugins.lookup.random_choice module¶
ansible.plugins.lookup.redis_kv module¶
ansible.plugins.lookup.sequence module¶
- 
class 
ansible.plugins.lookup.sequence.LookupModule(loader=None, templar=None, **kwargs)[source]¶ Bases:
ansible.plugins.lookup.LookupBasesequence lookup module
Used to generate some sequence of items. Takes arguments in two forms.
The simple / shortcut form is:
[start-]end[/stride][:format]As indicated by the brackets: start, stride, and format string are all optional. The format string is in the style of printf. This can be used to pad with zeros, format in hexadecimal, etc. All of the numerical values can be specified in octal (i.e. 0664) or hexadecimal (i.e. 0x3f8). Negative numbers are not supported.
Some examples:
5 -> [“1”,”2”,”3”,”4”,”5”] 5-8 -> [“5”, “6”, “7”, “8”] 2-10/2 -> [“2”, “4”, “6”, “8”, “10”] 4:host%02d -> [“host01”,”host02”,”host03”,”host04”]The standard Ansible key-value form is accepted as well. For example:
start=5 end=11 stride=2 format=0x%02x -> [“0x05”,”0x07”,”0x09”,”0x0a”]This format takes an alternate form of “end” called “count”, which counts some number from the starting value. For example:
count=5 -> [“1”, “2”, “3”, “4”, “5”] start=0x0f00 count=4 format=%04x -> [“0f00”, “0f01”, “0f02”, “0f03”] start=0 count=5 stride=2 -> [“0”, “2”, “4”, “6”, “8”] start=1 count=5 stride=2 -> [“1”, “3”, “5”, “7”, “9”]The count option is mostly useful for avoiding off-by-one errors and errors calculating the number of entries in a sequence when a stride is specified.
ansible.plugins.lookup.shelvefile module¶
ansible.plugins.lookup.subelements module¶
ansible.plugins.lookup.template module¶
ansible.plugins.lookup.together module¶
- 
class 
ansible.plugins.lookup.together.LookupModule(loader=None, templar=None, **kwargs)[source]¶ Bases:
ansible.plugins.lookup.LookupBaseTranspose a list of arrays: [1, 2, 3], [4, 5, 6] -> [1, 4], [2, 5], [3, 6] Replace any empty spots in 2nd array with None: [1, 2], [3] -> [1, 3], [2, None]