mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-02 22:43:23 -07:00
modules: fix examples to use FQCN for builtin modules (#648)
* modules: fix examples to use FQCN for builtin modules * fix * fix * fix * fix * fix * fix * fix
This commit is contained in:
parent
c034e8c04f
commit
c055340ecb
126 changed files with 290 additions and 286 deletions
|
@ -20,10 +20,10 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = """
|
||||
- name: Example of the change in the description
|
||||
debug: msg="{{ lookup('cartesian', [1,2,3], [a, b])}}"
|
||||
ansible.builtin.debug: msg="{{ lookup('cartesian', [1,2,3], [a, b])}}"
|
||||
|
||||
- name: loops over the cartesian product of the supplied lists
|
||||
debug: msg="{{item}}"
|
||||
ansible.builtin.debug: msg="{{item}}"
|
||||
with_cartesian:
|
||||
- "{{list1}}"
|
||||
- "{{list2}}"
|
||||
|
|
|
@ -27,7 +27,7 @@ DOCUMENTATION = '''
|
|||
'''
|
||||
|
||||
EXAMPLES = """
|
||||
- debug:
|
||||
- ansible.builtin.debug:
|
||||
msg: "{{ lookup('chef_databag', 'name=data_bag_name item=data_bag_item') }}"
|
||||
"""
|
||||
|
||||
|
|
|
@ -78,19 +78,19 @@ DOCUMENTATION = '''
|
|||
'''
|
||||
|
||||
EXAMPLES = """
|
||||
- debug:
|
||||
- ansible.builtin.debug:
|
||||
msg: 'key contains {{item}}'
|
||||
with_consul_kv:
|
||||
- 'key/to/retrieve'
|
||||
|
||||
- name: Parameters can be provided after the key be more specific about what to retrieve
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: 'key contains {{item}}'
|
||||
with_consul_kv:
|
||||
- 'key/to recurse=true token=E6C060A9-26FB-407A-B83E-12DDAFCB4D98'
|
||||
|
||||
- name: retrieving a KV from a remote cluster on non default port
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('consul_kv', 'my/key', host='10.10.10.10', port='2000') }}"
|
||||
"""
|
||||
|
||||
|
|
|
@ -44,16 +44,16 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = """
|
||||
- name: first use credstash to store your secrets
|
||||
shell: credstash put my-github-password secure123
|
||||
ansible.builtin.shell: credstash put my-github-password secure123
|
||||
|
||||
- name: "Test credstash lookup plugin -- get my github password"
|
||||
debug: msg="Credstash lookup! {{ lookup('credstash', 'my-github-password') }}"
|
||||
ansible.builtin.debug: msg="Credstash lookup! {{ lookup('credstash', 'my-github-password') }}"
|
||||
|
||||
- name: "Test credstash lookup plugin -- get my other password from us-west-1"
|
||||
debug: msg="Credstash lookup! {{ lookup('credstash', 'my-other-password', region='us-west-1') }}"
|
||||
ansible.builtin.debug: msg="Credstash lookup! {{ lookup('credstash', 'my-other-password', region='us-west-1') }}"
|
||||
|
||||
- name: "Test credstash lookup plugin -- get the company's github password"
|
||||
debug: msg="Credstash lookup! {{ lookup('credstash', 'company-github-password', table='company-passwords') }}"
|
||||
ansible.builtin.debug: msg="Credstash lookup! {{ lookup('credstash', 'company-github-password', table='company-passwords') }}"
|
||||
|
||||
- name: Example play using the 'context' feature
|
||||
hosts: localhost
|
||||
|
@ -64,10 +64,10 @@ EXAMPLES = """
|
|||
tasks:
|
||||
|
||||
- name: "Test credstash lookup plugin -- get the password with a context passed as a variable"
|
||||
debug: msg="{{ lookup('credstash', 'some-password', context=context) }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('credstash', 'some-password', context=context) }}"
|
||||
|
||||
- name: "Test credstash lookup plugin -- get the password with a context defined here"
|
||||
debug: msg="{{ lookup('credstash', 'some-password', context=dict(app='my_app', environment='production')) }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('credstash', 'some-password', context=dict(app='my_app', environment='production')) }}"
|
||||
"""
|
||||
|
||||
RETURN = """
|
||||
|
|
|
@ -36,7 +36,7 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = """
|
||||
- name: passing options to the lookup
|
||||
debug: msg={{ lookup("cyberarkpassword", cyquery)}}
|
||||
ansible.builtin.debug: msg={{ lookup("cyberarkpassword", cyquery)}}
|
||||
vars:
|
||||
cyquery:
|
||||
appid: "app_ansible"
|
||||
|
@ -45,7 +45,7 @@ EXAMPLES = """
|
|||
|
||||
|
||||
- name: used in a loop
|
||||
debug: msg={{item}}
|
||||
ansible.builtin.debug: msg={{item}}
|
||||
with_cyberarkpassword:
|
||||
appid: 'app_ansible'
|
||||
query: 'safe=CyberArk_Passwords;folder=root;object=AdminPass'
|
||||
|
|
|
@ -44,24 +44,24 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = """
|
||||
- name: Simple A record (IPV4 address) lookup for example.com
|
||||
debug: msg="{{ lookup('dig', 'example.com.')}}"
|
||||
ansible.builtin.debug: msg="{{ lookup('dig', 'example.com.')}}"
|
||||
|
||||
- name: "The TXT record for example.org."
|
||||
debug: msg="{{ lookup('dig', 'example.org.', 'qtype=TXT') }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('dig', 'example.org.', 'qtype=TXT') }}"
|
||||
|
||||
- name: "The TXT record for example.org, alternative syntax."
|
||||
debug: msg="{{ lookup('dig', 'example.org./TXT') }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('dig', 'example.org./TXT') }}"
|
||||
|
||||
- name: use in a loop
|
||||
debug: msg="MX record for gmail.com {{ item }}"
|
||||
ansible.builtin.debug: msg="MX record for gmail.com {{ item }}"
|
||||
with_items: "{{ lookup('dig', 'gmail.com./MX', wantlist=True) }}"
|
||||
|
||||
- debug: msg="Reverse DNS for 192.0.2.5 is {{ lookup('dig', '192.0.2.5/PTR') }}"
|
||||
- debug: msg="Reverse DNS for 192.0.2.5 is {{ lookup('dig', '5.2.0.192.in-addr.arpa./PTR') }}"
|
||||
- debug: msg="Reverse DNS for 192.0.2.5 is {{ lookup('dig', '5.2.0.192.in-addr.arpa.', 'qtype=PTR') }}"
|
||||
- debug: msg="Querying 198.51.100.23 for IPv4 address for example.com. produces {{ lookup('dig', 'example.com', '@198.51.100.23') }}"
|
||||
- ansible.builtin.debug: msg="Reverse DNS for 192.0.2.5 is {{ lookup('dig', '192.0.2.5/PTR') }}"
|
||||
- ansible.builtin.debug: msg="Reverse DNS for 192.0.2.5 is {{ lookup('dig', '5.2.0.192.in-addr.arpa./PTR') }}"
|
||||
- ansible.builtin.debug: msg="Reverse DNS for 192.0.2.5 is {{ lookup('dig', '5.2.0.192.in-addr.arpa.', 'qtype=PTR') }}"
|
||||
- ansible.builtin.debug: msg="Querying 198.51.100.23 for IPv4 address for example.com. produces {{ lookup('dig', 'example.com', '@198.51.100.23') }}"
|
||||
|
||||
- debug: msg="XMPP service for gmail.com. is available at {{ item.target }} on port {{ item.port }}"
|
||||
- ansible.builtin.debug: msg="XMPP service for gmail.com. is available at {{ item.target }} on port {{ item.port }}"
|
||||
with_items: "{{ lookup('dig', '_xmpp-server._tcp.gmail.com./SRV', 'flat=0', wantlist=True) }}"
|
||||
"""
|
||||
|
||||
|
|
|
@ -21,17 +21,17 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = """
|
||||
- name: show txt entry
|
||||
debug: msg="{{lookup('dnstxt', ['test.example.com'])}}"
|
||||
ansible.builtin.debug: msg="{{lookup('dnstxt', ['test.example.com'])}}"
|
||||
|
||||
- name: iterate over txt entries
|
||||
debug: msg="{{item}}"
|
||||
ansible.builtin.debug: msg="{{item}}"
|
||||
with_dnstxt:
|
||||
- 'test.example.com'
|
||||
- 'other.example.com'
|
||||
- 'last.example.com'
|
||||
|
||||
- name: iterate of a comma delimited DNS TXT entry
|
||||
debug: msg="{{item}}"
|
||||
ansible.builtin.debug: msg="{{item}}"
|
||||
with_dnstxt: "{{lookup('dnstxt', ['test.example.com']).split(',')}}"
|
||||
"""
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ EXAMPLES = r"""
|
|||
vars:
|
||||
secret: "{{ lookup('community.general.dsv', '/test/secret') }}"
|
||||
tasks:
|
||||
- debug:
|
||||
- ansible.builtin.debug:
|
||||
msg: 'the password is {{ secret["data"]["password"] }}'
|
||||
"""
|
||||
|
||||
|
|
|
@ -54,13 +54,13 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = '''
|
||||
- name: "a value from a locally running etcd"
|
||||
debug: msg={{ lookup('etcd', 'foo/bar') }}
|
||||
ansible.builtin.debug: msg={{ lookup('etcd', 'foo/bar') }}
|
||||
|
||||
- name: "values from multiple folders on a locally running etcd"
|
||||
debug: msg={{ lookup('etcd', 'foo', 'bar', 'baz') }}
|
||||
ansible.builtin.debug: msg={{ lookup('etcd', 'foo', 'bar', 'baz') }}
|
||||
|
||||
- name: "since Ansible 2.5 you can set server options inline"
|
||||
debug: msg="{{ lookup('etcd', 'foo', version='v2', url='http://192.168.0.27:4001') }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('etcd', 'foo', version='v2', url='http://192.168.0.27:4001') }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
|
@ -82,7 +82,7 @@ from ansible.module_utils.urls import open_url
|
|||
# If etcd v2 running on host 192.168.1.21 on port 2379
|
||||
# we can use the following in a playbook to retrieve /tfm/network/config key
|
||||
#
|
||||
# - debug: msg={{lookup('etcd','/tfm/network/config', url='http://192.168.1.21:2379' , version='v2')}}
|
||||
# - ansible.builtin.debug: msg={{lookup('etcd','/tfm/network/config', url='http://192.168.1.21:2379' , version='v2')}}
|
||||
#
|
||||
# Example Output:
|
||||
#
|
||||
|
|
|
@ -101,19 +101,19 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = '''
|
||||
- name: "a value from a locally running etcd"
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.etcd3', 'foo/bar') }}"
|
||||
|
||||
- name: "values from multiple folders on a locally running etcd"
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.etcd3', 'foo', 'bar', 'baz') }}"
|
||||
|
||||
- name: "look for a key prefix"
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.etcd3', '/foo/bar', prefix=True) }}"
|
||||
|
||||
- name: "connect to etcd3 with a client certificate"
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.etcd3', 'foo/bar', cert_cert='/etc/ssl/etcd/client.pem', cert_key='/etc/ssl/etcd/client.key') }}"
|
||||
'''
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ options:
|
|||
|
||||
EXAMPLES = """
|
||||
- name: Create directories
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: /web/{{ item.path }}
|
||||
state: directory
|
||||
mode: '{{ item.mode }}'
|
||||
|
@ -29,7 +29,7 @@ EXAMPLES = """
|
|||
when: item.state == 'directory'
|
||||
|
||||
- name: Template files (explicitly skip directories in order to use the 'src' attribute)
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: '{{ item.src }}'
|
||||
dest: /web/{{ item.path }}
|
||||
mode: '{{ item.mode }}'
|
||||
|
@ -37,7 +37,7 @@ EXAMPLES = """
|
|||
when: item.state == 'file'
|
||||
|
||||
- name: Recreate symlinks
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
src: '{{ item.src }}'
|
||||
dest: /web/{{ item.path }}
|
||||
state: link
|
||||
|
|
|
@ -21,7 +21,7 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = """
|
||||
- name: "'unnest' all elements into single list"
|
||||
debug: msg="all in one list {{lookup('flattened', [1,2,3,[5,6]], [a,b,c], [[5,6,1,3], [34,a,b,c]])}}"
|
||||
ansible.builtin.debug: msg="all in one list {{lookup('flattened', [1,2,3,[5,6]], [a,b,c], [[5,6,1,3], [34,a,b,c]])}}"
|
||||
"""
|
||||
|
||||
RETURN = """
|
||||
|
|
|
@ -29,7 +29,7 @@ extends_documentation_fragment:
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
- debug: msg="the value of foo.txt is {{ lookup('gcp_storage_file',
|
||||
- ansible.builtin.debug: msg="the value of foo.txt is {{ lookup('gcp_storage_file',
|
||||
bucket='gcp-bucket', src='mydir/foo.txt', project='project-name',
|
||||
auth_kind='serviceaccount', service_account_file='/tmp/myserviceaccountfile.json') }}"
|
||||
'''
|
||||
|
|
|
@ -161,79 +161,79 @@ DOCUMENTATION = """
|
|||
"""
|
||||
|
||||
EXAMPLES = """
|
||||
- debug:
|
||||
- ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.hashi_vault', 'secret=secret/hello:value token=c975b780-d1be-8016-866b-01d0f9b688a5 url=http://myvault:8200') }}"
|
||||
|
||||
- name: Return all secrets from a path
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.hashi_vault', 'secret=secret/hello token=c975b780-d1be-8016-866b-01d0f9b688a5 url=http://myvault:8200') }}"
|
||||
|
||||
- name: Vault that requires authentication via LDAP
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.hashi_vault', 'secret/hello:value auth_method=ldap mount_point=ldap username=myuser password=mypas') }}"
|
||||
|
||||
- name: Vault that requires authentication via username and password
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.hashi_vault', 'secret=secret/hello:value auth_method=userpass username=myuser password=psw url=http://myvault:8200') }}"
|
||||
|
||||
- name: Using an ssl vault
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.hashi_vault', 'secret=secret/hola:value token=c975b780-d1be-8016-866b-01d0f9b688a5 validate_certs=False') }}"
|
||||
|
||||
- name: using certificate auth
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.hashi_vault', 'secret/hi:value token=xxxx url=https://myvault:8200 validate_certs=True cacert=/cacert/path/ca.pem') }}"
|
||||
|
||||
- name: authenticate with a Vault app role
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.hashi_vault', 'secret=secret/hello:value auth_method=approle role_id=myroleid secret_id=mysecretid') }}"
|
||||
|
||||
- name: Return all secrets from a path in a namespace
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.hashi_vault', 'secret=secret/hello token=c975b780-d1be-8016-866b-01d0f9b688a5 namespace=teama/admins') }}"
|
||||
|
||||
# When using KV v2 the PATH should include "data" between the secret engine mount and path (e.g. "secret/data/:path")
|
||||
# see: https://www.vaultproject.io/api/secret/kv/kv-v2.html#read-secret-version
|
||||
- name: Return latest KV v2 secret from path
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.hashi_vault', 'secret=secret/data/hello token=my_vault_token url=http://myvault_url:8200') }}"
|
||||
|
||||
# The following examples work in collection releases after community.general 0.2.0
|
||||
|
||||
- name: secret= is not required if secret is first
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.hashi_vault', 'secret/data/hello token=<token> url=http://myvault_url:8200') }}"
|
||||
|
||||
- name: options can be specified as parameters rather than put in term string
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.hashi_vault', 'secret/data/hello', token=my_token_var, url='http://myvault_url:8200') }}"
|
||||
|
||||
# return_format (or its alias 'as') can control how secrets are returned to you
|
||||
- name: return secrets as a dict (default)
|
||||
set_fact:
|
||||
my_secrets: "{{ lookup('community.general.hashi_vault', 'secret/data/manysecrets', token=my_token_var, url='http://myvault_url:8200') }}"
|
||||
- debug:
|
||||
- ansible.builtin.debug:
|
||||
msg: "{{ my_secrets['secret_key'] }}"
|
||||
- debug:
|
||||
- ansible.builtin.debug:
|
||||
msg: "Secret '{{ item.key }}' has value '{{ item.value }}'"
|
||||
loop: "{{ my_secrets | dict2items }}"
|
||||
|
||||
- name: return secrets as values only
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "A secret value: {{ item }}"
|
||||
loop: "{{ query('community.general.hashi_vault', 'secret/data/manysecrets', token=my_token_var, url='http://myvault_url:8200', return_format='values') }}"
|
||||
|
||||
- name: return raw secret from API, including metadata
|
||||
set_fact:
|
||||
my_secret: "{{ lookup('community.general.hashi_vault', 'secret/data/hello:value', token=my_token_var, url='http://myvault_url:8200', as='raw') }}"
|
||||
- debug:
|
||||
- ansible.builtin.debug:
|
||||
msg: "This is version {{ my_secret['metadata']['version'] }} of hello:value. The secret data is {{ my_secret['data']['data']['value'] }}"
|
||||
|
||||
# AWS IAM authentication method
|
||||
# uses Ansible standard AWS options
|
||||
|
||||
- name: authenticate with aws_iam_login
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('community.general.hashi_vault', 'secret/hello:value', auth_method='aws_iam_login' role_id='myroleid', profile=my_boto_profile) }}"
|
||||
"""
|
||||
|
||||
|
|
|
@ -39,13 +39,13 @@ EXAMPLES = """
|
|||
# All this examples depends on hiera.yml that describes the hierarchy
|
||||
|
||||
- name: "a value from Hiera 'DB'"
|
||||
debug: msg={{ lookup('hiera', 'foo') }}
|
||||
ansible.builtin.debug: msg={{ lookup('hiera', 'foo') }}
|
||||
|
||||
- name: "a value from a Hiera 'DB' on other environment"
|
||||
debug: msg={{ lookup('hiera', 'foo environment=production') }}
|
||||
ansible.builtin.debug: msg={{ lookup('hiera', 'foo environment=production') }}
|
||||
|
||||
- name: "a value from a Hiera 'DB' for a concrete node"
|
||||
debug: msg={{ lookup('hiera', 'foo fqdn=puppet01.localdomain') }}
|
||||
ansible.builtin.debug: msg={{ lookup('hiera', 'foo fqdn=puppet01.localdomain') }}
|
||||
"""
|
||||
|
||||
RETURN = """
|
||||
|
|
|
@ -18,7 +18,7 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = """
|
||||
- name : output secrets to screen (BAD IDEA)
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "Password: {{item}}"
|
||||
with_keyring:
|
||||
- 'servicename username'
|
||||
|
|
|
@ -25,7 +25,7 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = """
|
||||
- name: get 'custom_field' from lastpass entry 'entry-name'
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('lastpass', 'entry-name', field='custom_field') }}"
|
||||
"""
|
||||
|
||||
|
|
|
@ -24,11 +24,11 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = """
|
||||
- name: query LMDB for a list of country codes
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ query('lmdb_kv', 'nl', 'be', 'lu', db='jp.mdb') }}"
|
||||
|
||||
- name: use list of values in a loop by key wildcard
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "Hello from {{ item.0 }} a.k.a. {{ item.1 }}"
|
||||
vars:
|
||||
- lmdb_kv_db: jp.mdb
|
||||
|
|
|
@ -40,11 +40,11 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = '''
|
||||
- name: all available resources
|
||||
debug: msg="{{ lookup('manifold', api_token='SecretToken') }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('manifold', api_token='SecretToken') }}"
|
||||
- name: all available resources for a specific project in specific team
|
||||
debug: msg="{{ lookup('manifold', api_token='SecretToken', project='poject-1', team='team-2') }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('manifold', api_token='SecretToken', project='poject-1', team='team-2') }}"
|
||||
- name: two specific resources
|
||||
debug: msg="{{ lookup('manifold', 'resource-1', 'resource-2') }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('manifold', 'resource-1', 'resource-2') }}"
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
|
|
|
@ -55,26 +55,26 @@ DOCUMENTATION = '''
|
|||
EXAMPLES = """
|
||||
# These examples only work when already signed in to 1Password
|
||||
- name: Retrieve password for KITT when already signed in to 1Password
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: lookup('onepassword', 'KITT')
|
||||
|
||||
- name: Retrieve password for Wintermute when already signed in to 1Password
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: lookup('onepassword', 'Tessier-Ashpool', section='Wintermute')
|
||||
|
||||
- name: Retrieve username for HAL when already signed in to 1Password
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: lookup('onepassword', 'HAL 9000', field='username', vault='Discovery')
|
||||
|
||||
- name: Retrieve password for HAL when not signed in to 1Password
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: lookup('onepassword'
|
||||
'HAL 9000'
|
||||
subdomain='Discovery'
|
||||
master_password=vault_master_password)
|
||||
|
||||
- name: Retrieve password for HAL when never signed in to 1Password
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: lookup('onepassword'
|
||||
'HAL 9000'
|
||||
subdomain='Discovery'
|
||||
|
|
|
@ -51,11 +51,11 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = """
|
||||
- name: Retrieve all data about Wintermute
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: lookup('onepassword_raw', 'Wintermute')
|
||||
|
||||
- name: Retrieve all data about Wintermute when not signed in to 1Password
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: lookup('onepassword_raw', 'Wintermute', subdomain='Turing', vault_password='DmbslfLvasjdl')
|
||||
"""
|
||||
|
||||
|
|
|
@ -57,28 +57,28 @@ DOCUMENTATION = '''
|
|||
EXAMPLES = """
|
||||
# Debug is used for examples, BAD IDEA to show passwords on screen
|
||||
- name: Basic lookup. Fails if example/test doesn't exist
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('passwordstore', 'example/test')}}"
|
||||
|
||||
- name: Create pass with random 16 character password. If password exists just give the password
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
var: mypassword
|
||||
vars:
|
||||
mypassword: "{{ lookup('passwordstore', 'example/test create=true')}}"
|
||||
|
||||
- name: Different size password
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('passwordstore', 'example/test create=true length=42')}}"
|
||||
|
||||
- name: Create password and overwrite the password if it exists. As a bonus, this module includes the old password inside the pass file
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('passwordstore', 'example/test create=true overwrite=true')}}"
|
||||
|
||||
- name: Create an alphanumeric password
|
||||
debug: msg="{{ lookup('passwordstore', 'example/test create=true nosymbols=true') }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('passwordstore', 'example/test create=true nosymbols=true') }}"
|
||||
|
||||
- name: Return the value for user in the KV pair user, username
|
||||
debug:
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ lookup('passwordstore', 'example/test subkey=user')}}"
|
||||
|
||||
- name: Return the entire password file content
|
||||
|
|
|
@ -46,17 +46,17 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = """
|
||||
- name: query redis for somekey (default or configured settings used)
|
||||
debug: msg="{{ lookup('redis', 'somekey') }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('redis', 'somekey') }}"
|
||||
|
||||
- name: query redis for list of keys and non-default host and port
|
||||
debug: msg="{{ lookup('redis', item, host='myredis.internal.com', port=2121) }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('redis', item, host='myredis.internal.com', port=2121) }}"
|
||||
loop: '{{list_of_redis_keys}}'
|
||||
|
||||
- name: use list directly
|
||||
debug: msg="{{ lookup('redis', 'key1', 'key2', 'key3') }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('redis', 'key1', 'key2', 'key3') }}"
|
||||
|
||||
- name: use list directly with a socket
|
||||
debug: msg="{{ lookup('redis', 'key1', 'key2', socket='/var/tmp/redis.sock') }}"
|
||||
ansible.builtin.debug: msg="{{ lookup('redis', 'key1', 'key2', socket='/var/tmp/redis.sock') }}"
|
||||
|
||||
"""
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ DOCUMENTATION = '''
|
|||
|
||||
EXAMPLES = """
|
||||
- name: retrieve a string value corresponding to a key inside a Python shelve file
|
||||
debug: msg="{{ lookup('shelvefile', 'file=path_to_some_shelve_file.db key=key_to_retrieve') }}
|
||||
ansible.builtin.debug: msg="{{ lookup('shelvefile', 'file=path_to_some_shelve_file.db key=key_to_retrieve') }}
|
||||
"""
|
||||
|
||||
RETURN = """
|
||||
|
|
|
@ -73,7 +73,7 @@ EXAMPLES = r"""
|
|||
vars:
|
||||
secret: "{{ lookup('community.general.tss', 1) }}"
|
||||
tasks:
|
||||
- debug: msg="the password is {{ (secret['items'] | items2dict(key_name='slug', value_name='itemValue'))['password'] }}"
|
||||
- ansible.builtin.debug: msg="the password is {{ (secret['items'] | items2dict(key_name='slug', value_name='itemValue'))['password'] }}"
|
||||
"""
|
||||
|
||||
from ansible.errors import AnsibleError, AnsibleOptionsError
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue