From 4c4a6ab27cc0ccd188f72d0a03d664f37486973b Mon Sep 17 00:00:00 2001 From: Andrew Klychkov Date: Thu, 16 Jul 2020 14:42:12 +0300 Subject: [PATCH] modules: fix examples to use FQCN for builtin plugins (#661) --- plugins/lookup/hashi_vault.py | 4 ++-- plugins/lookup/lmdb_kv.py | 2 +- plugins/lookup/nios.py | 12 ++++++------ plugins/lookup/nios_next_ip.py | 6 +++--- plugins/lookup/nios_next_network.py | 6 +++--- plugins/lookup/passwordstore.py | 2 +- plugins/modules/cloud/docker/docker_compose.py | 10 +++++----- plugins/modules/cloud/docker/docker_image_info.py | 2 +- plugins/modules/cloud/google/gce.py | 2 +- plugins/modules/cloud/opennebula/one_vm.py | 2 +- plugins/modules/cloud/packet/packet_device.py | 2 +- plugins/modules/cloud/rackspace/rax_facts.py | 2 +- .../modules/database/postgresql/postgresql_query.py | 2 +- .../remote_management/redfish/idrac_redfish_info.py | 6 +++--- .../modules/web_infrastructure/apache2_mod_proxy.py | 2 +- plugins/modules/web_infrastructure/jenkins_plugin.py | 8 ++++---- plugins/modules/web_infrastructure/jenkins_script.py | 2 +- 17 files changed, 36 insertions(+), 36 deletions(-) diff --git a/plugins/lookup/hashi_vault.py b/plugins/lookup/hashi_vault.py index 921a7c40eb..2c0eaaafa4 100644 --- a/plugins/lookup/hashi_vault.py +++ b/plugins/lookup/hashi_vault.py @@ -210,7 +210,7 @@ EXAMPLES = """ # return_format (or its alias 'as') can control how secrets are returned to you - 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') }}" - ansible.builtin.debug: 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') }}" - 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') }}" - ansible.builtin.debug: msg: "This is version {{ my_secret['metadata']['version'] }} of hello:value. The secret data is {{ my_secret['data']['data']['value'] }}" diff --git a/plugins/lookup/lmdb_kv.py b/plugins/lookup/lmdb_kv.py index 6c5da9db1b..f760eaaaec 100644 --- a/plugins/lookup/lmdb_kv.py +++ b/plugins/lookup/lmdb_kv.py @@ -36,7 +36,7 @@ EXAMPLES = """ - "n*" - name: get an item by key - assert: + ansible.builtin.assert: that: - item == 'Belgium' vars: diff --git a/plugins/lookup/nios.py b/plugins/lookup/nios.py index f5ba195010..580d7836fc 100644 --- a/plugins/lookup/nios.py +++ b/plugins/lookup/nios.py @@ -47,11 +47,11 @@ options: EXAMPLES = """ - name: fetch all networkview objects - set_fact: + ansible.builtin.set_fact: networkviews: "{{ lookup('nios', 'networkview', provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" - 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'}) }}" # all of the examples below use credentials that are set using env variables @@ -60,20 +60,20 @@ EXAMPLES = """ # export INFOBLOX_PASSWORD=admin - 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']}) }}" - name: use env variables to pass credentials - set_fact: + ansible.builtin.set_fact: networkviews: "{{ lookup('nios', 'networkview') }}" - name: get a host record - set_fact: + ansible.builtin.set_fact: host: "{{ lookup('nios', 'record:host', filter={'name': 'hostname.ansible.com'}) }}" - 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'}) }}" """ diff --git a/plugins/lookup/nios_next_ip.py b/plugins/lookup/nios_next_ip.py index 62d0954044..bbd38f8b16 100644 --- a/plugins/lookup/nios_next_ip.py +++ b/plugins/lookup/nios_next_ip.py @@ -47,15 +47,15 @@ options: EXAMPLES = """ - 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'}) }}" - 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'}) }}" - 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'], provider={'host': 'nios01', 'username': 'admin', 'password': 'password'}) }}" """ diff --git a/plugins/lookup/nios_next_network.py b/plugins/lookup/nios_next_network.py index f0aab7abd7..bc3f21d6bc 100644 --- a/plugins/lookup/nios_next_network.py +++ b/plugins/lookup/nios_next_network.py @@ -55,16 +55,16 @@ options: EXAMPLES = """ - 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'}) }}" - 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, 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' - set_fact: + ansible.builtin.set_fact: 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'}) }}" """ diff --git a/plugins/lookup/passwordstore.py b/plugins/lookup/passwordstore.py index 5325503cd8..1ab1d56f4e 100644 --- a/plugins/lookup/passwordstore.py +++ b/plugins/lookup/passwordstore.py @@ -82,7 +82,7 @@ EXAMPLES = """ msg: "{{ lookup('passwordstore', 'example/test subkey=user')}}" - name: Return the entire password file content - set_fact: + ansible.builtin.set_fact: passfilecontent: "{{ lookup('passwordstore', 'example/test returnall=true')}}" """ diff --git a/plugins/modules/cloud/docker/docker_compose.py b/plugins/modules/cloud/docker/docker_compose.py index f6451da611..96f89e6cef 100644 --- a/plugins/modules/cloud/docker/docker_compose.py +++ b/plugins/modules/cloud/docker/docker_compose.py @@ -189,7 +189,7 @@ EXAMPLES = ''' - ansible.builtin.debug: var: output - - assert: + - ansible.builtin.assert: that: "not output.changed " - name: Stop all services @@ -202,7 +202,7 @@ EXAMPLES = ''' - ansible.builtin.debug: var: output - - assert: + - ansible.builtin.assert: that: - "not web.flask_web_1.state.running" - "not db.flask_db_1.state.running" @@ -217,7 +217,7 @@ EXAMPLES = ''' - ansible.builtin.debug: var: output - - assert: + - ansible.builtin.assert: that: - "web.flask_web_1.state.running" - "db.flask_db_1.state.running" @@ -264,7 +264,7 @@ EXAMPLES = ''' - ansible.builtin.debug: var: output - - assert: + - ansible.builtin.assert: that: - "web.flask_web_1.state.running" - "db.flask_db_1.state.running" @@ -296,7 +296,7 @@ EXAMPLES = ''' - ansible.builtin.debug: var: output - - assert: + - ansible.builtin.assert: that: - "web.flask_web_1.state.running" - "db.flask_db_1.state.running" diff --git a/plugins/modules/cloud/docker/docker_image_info.py b/plugins/modules/cloud/docker/docker_image_info.py index 4f052ff5e8..8cf08ef08e 100644 --- a/plugins/modules/cloud/docker/docker_image_info.py +++ b/plugins/modules/cloud/docker/docker_image_info.py @@ -62,7 +62,7 @@ EXAMPLES = ''' register: result - name: Make sure that both images pacur/centos-7 and sinatra exist locally - assert: + ansible.builtin.assert: that: - result.images | length == 2 ''' diff --git a/plugins/modules/cloud/google/gce.py b/plugins/modules/cloud/google/gce.py index 777938869b..3bafdf54a1 100644 --- a/plugins/modules/cloud/google/gce.py +++ b/plugins/modules/cloud/google/gce.py @@ -242,7 +242,7 @@ EXAMPLES = ''' with_items: "{{ gce.instance_data }}" - name: Wait for SSH for instances - wait_for: + ansible.builtin.wait_for: delay: 1 host: "{{ item.public_ip }}" port: 22 diff --git a/plugins/modules/cloud/opennebula/one_vm.py b/plugins/modules/cloud/opennebula/one_vm.py index 3ee38aa10a..55f51012ad 100644 --- a/plugins/modules/cloud/opennebula/one_vm.py +++ b/plugins/modules/cloud/opennebula/one_vm.py @@ -327,7 +327,7 @@ EXAMPLES = ''' register: vm - name: Wait for SSH to come up - wait_for_connection: + ansible.builtin.wait_for_connection: delegate_to: '{{ vm.instances[0].networks[0].ip }}' - name: Terminate VMs by ids diff --git a/plugins/modules/cloud/packet/packet_device.py b/plugins/modules/cloud/packet/packet_device.py index 0a596dfe7b..c76530f552 100644 --- a/plugins/modules/cloud/packet/packet_device.py +++ b/plugins/modules/cloud/packet/packet_device.py @@ -208,7 +208,7 @@ EXAMPLES = ''' register: newhosts - name: Wait for ssh - wait_for: + ansible.builtin.wait_for: delay: 1 host: "{{ item.public_ipv4 }}" port: 22 diff --git a/plugins/modules/cloud/rackspace/rax_facts.py b/plugins/modules/cloud/rackspace/rax_facts.py index 2ced4a1d41..4508f7303f 100644 --- a/plugins/modules/cloud/rackspace/rax_facts.py +++ b/plugins/modules/cloud/rackspace/rax_facts.py @@ -41,7 +41,7 @@ EXAMPLES = ''' name: "{{ inventory_hostname }}" region: DFW - name: Map some facts - set_fact: + ansible.builtin.set_fact: ansible_ssh_host: "{{ rax_accessipv4 }}" ''' diff --git a/plugins/modules/database/postgresql/postgresql_query.py b/plugins/modules/database/postgresql/postgresql_query.py index 9a109c05c1..a4c0a408d0 100644 --- a/plugins/modules/database/postgresql/postgresql_query.py +++ b/plugins/modules/database/postgresql/postgresql_query.py @@ -139,7 +139,7 @@ EXAMPLES = r''' # Pass list and string vars as positional_args - name: Set vars - set_fact: + ansible.builtin.set_fact: my_list: - 1 - 2 diff --git a/plugins/modules/remote_management/redfish/idrac_redfish_info.py b/plugins/modules/remote_management/redfish/idrac_redfish_info.py index 42f27cb1b9..f5b7fe1af9 100644 --- a/plugins/modules/remote_management/redfish/idrac_redfish_info.py +++ b/plugins/modules/remote_management/redfish/idrac_redfish_info.py @@ -67,7 +67,7 @@ EXAMPLES = ''' # Examples to display the value of all or a single iDRAC attribute - 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 }}" - name: Display all iDRAC attributes @@ -80,7 +80,7 @@ EXAMPLES = ''' # Examples to display the value of all or a single LifecycleController attribute - 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 }}" - name: Display LifecycleController attributes @@ -93,7 +93,7 @@ EXAMPLES = ''' # Examples to display the value of all or a single System attribute - 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 }}" - name: Display System attributes diff --git a/plugins/modules/web_infrastructure/apache2_mod_proxy.py b/plugins/modules/web_infrastructure/apache2_mod_proxy.py index cff5283ecc..96c07c4a07 100644 --- a/plugins/modules/web_infrastructure/apache2_mod_proxy.py +++ b/plugins/modules/web_infrastructure/apache2_mod_proxy.py @@ -86,7 +86,7 @@ EXAMPLES = ''' delegate_to: myloadbalancernode - name: Step 2 - wait_for: + ansible.builtin.wait_for: host: '{{ member.host }}' port: '{{ member.port }}' state: drained diff --git a/plugins/modules/web_infrastructure/jenkins_plugin.py b/plugins/modules/web_infrastructure/jenkins_plugin.py index 39fc4c5385..3364dd6390 100644 --- a/plugins/modules/web_infrastructure/jenkins_plugin.py +++ b/plugins/modules/web_infrastructure/jenkins_plugin.py @@ -188,17 +188,17 @@ EXAMPLES = ''' with_dict: "{{ my_jenkins_plugins }}" - name: Initiate the fact - set_fact: + ansible.builtin.set_fact: jenkins_restart_required: no - name: Check if restart is required by any of the versioned plugins - set_fact: + ansible.builtin.set_fact: jenkins_restart_required: yes when: item.changed with_items: "{{ my_jenkins_plugin_versioned.results }}" - name: Check if restart is required by any of the unversioned plugins - set_fact: + ansible.builtin.set_fact: jenkins_restart_required: yes when: item.changed with_items: "{{ my_jenkins_plugin_unversioned.results }}" @@ -224,7 +224,7 @@ EXAMPLES = ''' when: jenkins_restart_required - name: Reset the fact - set_fact: + ansible.builtin.set_fact: jenkins_restart_required: no when: jenkins_restart_required diff --git a/plugins/modules/web_infrastructure/jenkins_script.py b/plugins/modules/web_infrastructure/jenkins_script.py index 0439242fc9..6fcfe6e4bc 100644 --- a/plugins/modules/web_infrastructure/jenkins_script.py +++ b/plugins/modules/web_infrastructure/jenkins_script.py @@ -65,7 +65,7 @@ EXAMPLES = ''' password: admin - name: Setting master using a variable to hold a more complicate script - set_fact: + ansible.builtin.set_fact: setmaster_mode: | import jenkins.model.* instance = Jenkins.getInstance()