1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

modules: fix examples to use FQCN for builtin plugins (#661)

This commit is contained in:
Andrew Klychkov 2020-07-16 14:42:12 +03:00 committed by GitHub
parent 2c3efea14b
commit 4c4a6ab27c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 36 additions and 36 deletions

View file

@ -210,7 +210,7 @@ EXAMPLES = """
# return_format (or its alias 'as') can control how secrets are returned to you # return_format (or its alias 'as') can control how secrets are returned to you
- name: return secrets as a dict (default) - name: return secrets as a dict (default)
set_fact: ansible.builtin.set_fact:
my_secrets: "{{ lookup('community.general.hashi_vault', 'secret/data/manysecrets', token=my_token_var, url='http://myvault_url:8200') }}" my_secrets: "{{ lookup('community.general.hashi_vault', 'secret/data/manysecrets', token=my_token_var, url='http://myvault_url:8200') }}"
- ansible.builtin.debug: - ansible.builtin.debug:
msg: "{{ my_secrets['secret_key'] }}" msg: "{{ my_secrets['secret_key'] }}"
@ -224,7 +224,7 @@ EXAMPLES = """
loop: "{{ query('community.general.hashi_vault', 'secret/data/manysecrets', token=my_token_var, url='http://myvault_url:8200', return_format='values') }}" 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 - name: return raw secret from API, including metadata
set_fact: ansible.builtin.set_fact:
my_secret: "{{ lookup('community.general.hashi_vault', 'secret/data/hello:value', token=my_token_var, url='http://myvault_url:8200', as='raw') }}" my_secret: "{{ lookup('community.general.hashi_vault', 'secret/data/hello:value', token=my_token_var, url='http://myvault_url:8200', as='raw') }}"
- ansible.builtin.debug: - ansible.builtin.debug:
msg: "This is version {{ my_secret['metadata']['version'] }} of hello:value. The secret data is {{ my_secret['data']['data']['value'] }}" msg: "This is version {{ my_secret['metadata']['version'] }} of hello:value. The secret data is {{ my_secret['data']['data']['value'] }}"

View file

@ -36,7 +36,7 @@ EXAMPLES = """
- "n*" - "n*"
- name: get an item by key - name: get an item by key
assert: ansible.builtin.assert:
that: that:
- item == 'Belgium' - item == 'Belgium'
vars: vars:

View file

@ -47,11 +47,11 @@ options:
EXAMPLES = """ EXAMPLES = """
- name: fetch all networkview objects - name: fetch all networkview objects
set_fact: ansible.builtin.set_fact:
networkviews: "{{ lookup('nios', 'networkview', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" networkviews: "{{ lookup('nios', 'networkview', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"
- name: fetch the default dns view - name: fetch the default dns view
set_fact: ansible.builtin.set_fact:
dns_views: "{{ lookup('nios', 'view', filter={'name': 'default'}, provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" dns_views: "{{ lookup('nios', 'view', filter={'name': 'default'}, provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"
# all of the examples below use credentials that are set using env variables # all of the examples below use credentials that are set using env variables
@ -60,20 +60,20 @@ EXAMPLES = """
# export INFOBLOX_PASSWORD=admin # export INFOBLOX_PASSWORD=admin
- name: fetch all host records and include extended attributes - name: fetch all host records and include extended attributes
set_fact: ansible.builtin.set_fact:
host_records: "{{ lookup('nios', 'record:host', return_fields=['extattrs', 'name', 'view', 'comment']}) }}" host_records: "{{ lookup('nios', 'record:host', return_fields=['extattrs', 'name', 'view', 'comment']}) }}"
- name: use env variables to pass credentials - name: use env variables to pass credentials
set_fact: ansible.builtin.set_fact:
networkviews: "{{ lookup('nios', 'networkview') }}" networkviews: "{{ lookup('nios', 'networkview') }}"
- name: get a host record - name: get a host record
set_fact: ansible.builtin.set_fact:
host: "{{ lookup('nios', 'record:host', filter={'name': 'hostname.ansible.com'}) }}" host: "{{ lookup('nios', 'record:host', filter={'name': 'hostname.ansible.com'}) }}"
- name: get the authoritative zone from a non default dns view - name: get the authoritative zone from a non default dns view
set_fact: ansible.builtin.set_fact:
host: "{{ lookup('nios', 'zone_auth', filter={'fqdn': 'ansible.com', 'view': 'ansible-dns'}) }}" host: "{{ lookup('nios', 'zone_auth', filter={'fqdn': 'ansible.com', 'view': 'ansible-dns'}) }}"
""" """

View file

@ -47,15 +47,15 @@ options:
EXAMPLES = """ EXAMPLES = """
- name: return next available IP address for network 192.168.10.0/24 - name: return next available IP address for network 192.168.10.0/24
set_fact: ansible.builtin.set_fact:
ipaddr: "{{ lookup('nios_next_ip', '192.168.10.0/24', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" ipaddr: "{{ lookup('nios_next_ip', '192.168.10.0/24', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"
- name: return the next 3 available IP addresses for network 192.168.10.0/24 - name: return the next 3 available IP addresses for network 192.168.10.0/24
set_fact: ansible.builtin.set_fact:
ipaddr: "{{ lookup('nios_next_ip', '192.168.10.0/24', num=3, provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" ipaddr: "{{ lookup('nios_next_ip', '192.168.10.0/24', num=3, provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"
- name: return the next 3 available IP addresses for network 192.168.10.0/24 excluding ip addresses - ['192.168.10.1', '192.168.10.2'] - name: return the next 3 available IP addresses for network 192.168.10.0/24 excluding ip addresses - ['192.168.10.1', '192.168.10.2']
set_fact: ansible.builtin.set_fact:
ipaddr: "{{ lookup('nios_next_ip', '192.168.10.0/24', num=3, exclude=['192.168.10.1', '192.168.10.2'], ipaddr: "{{ lookup('nios_next_ip', '192.168.10.0/24', num=3, exclude=['192.168.10.1', '192.168.10.2'],
provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"
""" """

View file

@ -55,16 +55,16 @@ options:
EXAMPLES = """ EXAMPLES = """
- name: return next available network for network-container 192.168.10.0/24 - name: return next available network for network-container 192.168.10.0/24
set_fact: ansible.builtin.set_fact:
networkaddr: "{{ lookup('nios_next_network', '192.168.10.0/24', cidr=25, provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" networkaddr: "{{ lookup('nios_next_network', '192.168.10.0/24', cidr=25, provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"
- name: return the next 2 available network addresses for network-container 192.168.10.0/24 - name: return the next 2 available network addresses for network-container 192.168.10.0/24
set_fact: ansible.builtin.set_fact:
networkaddr: "{{ lookup('nios_next_network', '192.168.10.0/24', cidr=25, num=2, networkaddr: "{{ lookup('nios_next_network', '192.168.10.0/24', cidr=25, num=2,
provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"
- name: return the available network addresses for network-container 192.168.10.0/24 excluding network range '192.168.10.0/25' - name: return the available network addresses for network-container 192.168.10.0/24 excluding network range '192.168.10.0/25'
set_fact: ansible.builtin.set_fact:
networkaddr: "{{ lookup('nios_next_network', '192.168.10.0/24', cidr=25, exclude=['192.168.10.0/25'], networkaddr: "{{ lookup('nios_next_network', '192.168.10.0/24', cidr=25, exclude=['192.168.10.0/25'],
provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}"
""" """

View file

@ -82,7 +82,7 @@ EXAMPLES = """
msg: "{{ lookup('passwordstore', 'example/test subkey=user')}}" msg: "{{ lookup('passwordstore', 'example/test subkey=user')}}"
- name: Return the entire password file content - name: Return the entire password file content
set_fact: ansible.builtin.set_fact:
passfilecontent: "{{ lookup('passwordstore', 'example/test returnall=true')}}" passfilecontent: "{{ lookup('passwordstore', 'example/test returnall=true')}}"
""" """

View file

@ -189,7 +189,7 @@ EXAMPLES = '''
- ansible.builtin.debug: - ansible.builtin.debug:
var: output var: output
- assert: - ansible.builtin.assert:
that: "not output.changed " that: "not output.changed "
- name: Stop all services - name: Stop all services
@ -202,7 +202,7 @@ EXAMPLES = '''
- ansible.builtin.debug: - ansible.builtin.debug:
var: output var: output
- assert: - ansible.builtin.assert:
that: that:
- "not web.flask_web_1.state.running" - "not web.flask_web_1.state.running"
- "not db.flask_db_1.state.running" - "not db.flask_db_1.state.running"
@ -217,7 +217,7 @@ EXAMPLES = '''
- ansible.builtin.debug: - ansible.builtin.debug:
var: output var: output
- assert: - ansible.builtin.assert:
that: that:
- "web.flask_web_1.state.running" - "web.flask_web_1.state.running"
- "db.flask_db_1.state.running" - "db.flask_db_1.state.running"
@ -264,7 +264,7 @@ EXAMPLES = '''
- ansible.builtin.debug: - ansible.builtin.debug:
var: output var: output
- assert: - ansible.builtin.assert:
that: that:
- "web.flask_web_1.state.running" - "web.flask_web_1.state.running"
- "db.flask_db_1.state.running" - "db.flask_db_1.state.running"
@ -296,7 +296,7 @@ EXAMPLES = '''
- ansible.builtin.debug: - ansible.builtin.debug:
var: output var: output
- assert: - ansible.builtin.assert:
that: that:
- "web.flask_web_1.state.running" - "web.flask_web_1.state.running"
- "db.flask_db_1.state.running" - "db.flask_db_1.state.running"

View file

@ -62,7 +62,7 @@ EXAMPLES = '''
register: result register: result
- name: Make sure that both images pacur/centos-7 and sinatra exist locally - name: Make sure that both images pacur/centos-7 and sinatra exist locally
assert: ansible.builtin.assert:
that: that:
- result.images | length == 2 - result.images | length == 2
''' '''

View file

@ -242,7 +242,7 @@ EXAMPLES = '''
with_items: "{{ gce.instance_data }}" with_items: "{{ gce.instance_data }}"
- name: Wait for SSH for instances - name: Wait for SSH for instances
wait_for: ansible.builtin.wait_for:
delay: 1 delay: 1
host: "{{ item.public_ip }}" host: "{{ item.public_ip }}"
port: 22 port: 22

View file

@ -327,7 +327,7 @@ EXAMPLES = '''
register: vm register: vm
- name: Wait for SSH to come up - name: Wait for SSH to come up
wait_for_connection: ansible.builtin.wait_for_connection:
delegate_to: '{{ vm.instances[0].networks[0].ip }}' delegate_to: '{{ vm.instances[0].networks[0].ip }}'
- name: Terminate VMs by ids - name: Terminate VMs by ids

View file

@ -208,7 +208,7 @@ EXAMPLES = '''
register: newhosts register: newhosts
- name: Wait for ssh - name: Wait for ssh
wait_for: ansible.builtin.wait_for:
delay: 1 delay: 1
host: "{{ item.public_ipv4 }}" host: "{{ item.public_ipv4 }}"
port: 22 port: 22

View file

@ -41,7 +41,7 @@ EXAMPLES = '''
name: "{{ inventory_hostname }}" name: "{{ inventory_hostname }}"
region: DFW region: DFW
- name: Map some facts - name: Map some facts
set_fact: ansible.builtin.set_fact:
ansible_ssh_host: "{{ rax_accessipv4 }}" ansible_ssh_host: "{{ rax_accessipv4 }}"
''' '''

View file

@ -139,7 +139,7 @@ EXAMPLES = r'''
# Pass list and string vars as positional_args # Pass list and string vars as positional_args
- name: Set vars - name: Set vars
set_fact: ansible.builtin.set_fact:
my_list: my_list:
- 1 - 1
- 2 - 2

View file

@ -67,7 +67,7 @@ EXAMPLES = '''
# Examples to display the value of all or a single iDRAC attribute # Examples to display the value of all or a single iDRAC attribute
- name: Store iDRAC attributes as a fact variable - name: Store iDRAC attributes as a fact variable
set_fact: ansible.builtin.set_fact:
idrac_attributes: "{{ result.redfish_facts.entries | selectattr('Id', 'defined') | selectattr('Id', 'equalto', 'iDRACAttributes') | list | first }}" idrac_attributes: "{{ result.redfish_facts.entries | selectattr('Id', 'defined') | selectattr('Id', 'equalto', 'iDRACAttributes') | list | first }}"
- name: Display all iDRAC attributes - name: Display all iDRAC attributes
@ -80,7 +80,7 @@ EXAMPLES = '''
# Examples to display the value of all or a single LifecycleController attribute # Examples to display the value of all or a single LifecycleController attribute
- name: Store LifecycleController attributes as a fact variable - name: Store LifecycleController attributes as a fact variable
set_fact: ansible.builtin.set_fact:
lc_attributes: "{{ result.redfish_facts.entries | selectattr('Id', 'defined') | selectattr('Id', 'equalto', 'LCAttributes') | list | first }}" lc_attributes: "{{ result.redfish_facts.entries | selectattr('Id', 'defined') | selectattr('Id', 'equalto', 'LCAttributes') | list | first }}"
- name: Display LifecycleController attributes - name: Display LifecycleController attributes
@ -93,7 +93,7 @@ EXAMPLES = '''
# Examples to display the value of all or a single System attribute # Examples to display the value of all or a single System attribute
- name: Store System attributes as a fact variable - name: Store System attributes as a fact variable
set_fact: ansible.builtin.set_fact:
system_attributes: "{{ result.redfish_facts.entries | selectattr('Id', 'defined') | selectattr('Id', 'equalto', 'SystemAttributes') | list | first }}" system_attributes: "{{ result.redfish_facts.entries | selectattr('Id', 'defined') | selectattr('Id', 'equalto', 'SystemAttributes') | list | first }}"
- name: Display System attributes - name: Display System attributes

View file

@ -86,7 +86,7 @@ EXAMPLES = '''
delegate_to: myloadbalancernode delegate_to: myloadbalancernode
- name: Step 2 - name: Step 2
wait_for: ansible.builtin.wait_for:
host: '{{ member.host }}' host: '{{ member.host }}'
port: '{{ member.port }}' port: '{{ member.port }}'
state: drained state: drained

View file

@ -188,17 +188,17 @@ EXAMPLES = '''
with_dict: "{{ my_jenkins_plugins }}" with_dict: "{{ my_jenkins_plugins }}"
- name: Initiate the fact - name: Initiate the fact
set_fact: ansible.builtin.set_fact:
jenkins_restart_required: no jenkins_restart_required: no
- name: Check if restart is required by any of the versioned plugins - name: Check if restart is required by any of the versioned plugins
set_fact: ansible.builtin.set_fact:
jenkins_restart_required: yes jenkins_restart_required: yes
when: item.changed when: item.changed
with_items: "{{ my_jenkins_plugin_versioned.results }}" with_items: "{{ my_jenkins_plugin_versioned.results }}"
- name: Check if restart is required by any of the unversioned plugins - name: Check if restart is required by any of the unversioned plugins
set_fact: ansible.builtin.set_fact:
jenkins_restart_required: yes jenkins_restart_required: yes
when: item.changed when: item.changed
with_items: "{{ my_jenkins_plugin_unversioned.results }}" with_items: "{{ my_jenkins_plugin_unversioned.results }}"
@ -224,7 +224,7 @@ EXAMPLES = '''
when: jenkins_restart_required when: jenkins_restart_required
- name: Reset the fact - name: Reset the fact
set_fact: ansible.builtin.set_fact:
jenkins_restart_required: no jenkins_restart_required: no
when: jenkins_restart_required when: jenkins_restart_required

View file

@ -65,7 +65,7 @@ EXAMPLES = '''
password: admin password: admin
- name: Setting master using a variable to hold a more complicate script - name: Setting master using a variable to hold a more complicate script
set_fact: ansible.builtin.set_fact:
setmaster_mode: | setmaster_mode: |
import jenkins.model.* import jenkins.model.*
instance = Jenkins.getInstance() instance = Jenkins.getInstance()