First batch _facts -> _info rename. (#56822)

This commit is contained in:
Felix Fontein 2019-05-27 18:17:42 +02:00 committed by GitHub
parent 4f8abde081
commit 7a0af34ba9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 91 additions and 65 deletions

View file

@ -0,0 +1,5 @@
minor_changes:
- The ``python_requirements_facts`` module has been renamed to ``python_requirements_info``.
- The ``zabbix_group_facts`` module has been renamed to ``zabbix_group_info``.
- The ``zabbix_host_facts`` module has been renamed to ``zabbix_host_info``.
- The ``k8s_facts`` module has been renamed to ``k8s_info``.

View file

@ -69,6 +69,11 @@ Noteworthy module changes
* `vmware_dvswitch <vmware_dvswitch_module>` accepts `folder` parameter to place dvswitch in user defined folder. This option makes `datacenter` as an optional parameter. * `vmware_dvswitch <vmware_dvswitch_module>` accepts `folder` parameter to place dvswitch in user defined folder. This option makes `datacenter` as an optional parameter.
* `vmware_datastore_cluster <vmware_datastore_cluster_module>` accepts `folder` parameter to place datastore cluster in user defined folder. This option makes `datacenter` as an optional parameter. * `vmware_datastore_cluster <vmware_datastore_cluster_module>` accepts `folder` parameter to place datastore cluster in user defined folder. This option makes `datacenter` as an optional parameter.
* The ``python_requirements_facts`` module was renamed to :ref:`python_requirements_info <python_requirements_info_module>`.
* The ``zabbix_group_facts`` module was renamed to :ref:`zabbix_group_info <zabbix_group_info_module>`.
* The ``zabbix_host_facts`` module was renamed to :ref:`zabbix_host_info <zabbix_host_info_module>`.
* The ``k8s_facts`` module was renamed to :ref:`k8s_info <k8s_info_module>`.
Plugins Plugins
======= =======

View file

@ -0,0 +1 @@
k8s_info.py

View file

@ -30,7 +30,7 @@ description:
- Pass the object definition from a source file or inline. See examples for reading - Pass the object definition from a source file or inline. See examples for reading
files and using Jinja templates or vault-encrypted files. files and using Jinja templates or vault-encrypted files.
- Access to the full range of K8s APIs. - Access to the full range of K8s APIs.
- Use the M(k8s_facts) module to obtain a list of items about an object of type C(kind) - Use the M(k8s_info) module to obtain a list of items about an object of type C(kind)
- Authenticate using either a config file, certificates, password or token. - Authenticate using either a config file, certificates, password or token.
- Supports check mode. - Supports check mode.

View file

@ -96,7 +96,7 @@ EXAMPLES = '''
# Previous task provides the token/api_key, while all other parameters # Previous task provides the token/api_key, while all other parameters
# are taken from module_defaults # are taken from module_defaults
- name: Get a list of all pods from any namespace - name: Get a list of all pods from any namespace
k8s_facts: k8s_info:
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}" api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
kind: Pod kind: Pod
register: pod_list register: pod_list

View file

@ -14,7 +14,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
'supported_by': 'community'} 'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = '''
module: k8s_facts module: k8s_info
short_description: Describe Kubernetes (K8s) objects short_description: Describe Kubernetes (K8s) objects
@ -28,6 +28,7 @@ description:
- Access to the full range of K8s APIs. - Access to the full range of K8s APIs.
- Authenticate using either a config file, certificates, password or token. - Authenticate using either a config file, certificates, password or token.
- Supports check mode. - Supports check mode.
- This module was called C(k8s_facts) before Ansible 2.9. The usage did not change.
options: options:
api_version: api_version:
@ -67,7 +68,7 @@ requirements:
EXAMPLES = ''' EXAMPLES = '''
- name: Get an existing Service object - name: Get an existing Service object
k8s_facts: k8s_info:
api_version: v1 api_version: v1
kind: Service kind: Service
name: web name: web
@ -75,26 +76,26 @@ EXAMPLES = '''
register: web_service register: web_service
- name: Get a list of all service objects - name: Get a list of all service objects
k8s_facts: k8s_info:
api_version: v1 api_version: v1
kind: Service kind: Service
namespace: testing namespace: testing
register: service_list register: service_list
- name: Get a list of all pods from any namespace - name: Get a list of all pods from any namespace
k8s_facts: k8s_info:
kind: Pod kind: Pod
register: pod_list register: pod_list
- name: Search for all Pods labelled app=web - name: Search for all Pods labelled app=web
k8s_facts: k8s_info:
kind: Pod kind: Pod
label_selectors: label_selectors:
- app = web - app = web
- tier in (dev, test) - tier in (dev, test)
- name: Search for all running pods - name: Search for all running pods
k8s_facts: k8s_info:
kind: Pod kind: Pod
field_selectors: field_selectors:
- status.phase=Running - status.phase=Running
@ -134,12 +135,14 @@ from ansible.module_utils.k8s.common import KubernetesAnsibleModule, AUTH_ARG_SP
import copy import copy
class KubernetesFactsModule(KubernetesAnsibleModule): class KubernetesInfoModule(KubernetesAnsibleModule):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
KubernetesAnsibleModule.__init__(self, *args, KubernetesAnsibleModule.__init__(self, *args,
supports_check_mode=True, supports_check_mode=True,
**kwargs) **kwargs)
if self._name == 'k8s_facts':
self.deprecate("The 'k8s_facts' module has been renamed to 'k8s_info'", version='2.13')
def execute_module(self): def execute_module(self):
self.client = self.get_api_client() self.client = self.get_api_client()
@ -169,7 +172,7 @@ class KubernetesFactsModule(KubernetesAnsibleModule):
def main(): def main():
KubernetesFactsModule().execute_module() KubernetesInfoModule().execute_module()
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -0,0 +1 @@
zabbix_group_info.py

View file

@ -0,0 +1 @@
zabbix_host_info.py

View file

@ -23,10 +23,11 @@ host_groups:
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: zabbix_group_facts module: zabbix_group_info
short_description: Gather facts about Zabbix hostgroup short_description: Gather information about Zabbix hostgroup
description: description:
- This module allows you to search for Zabbix hostgroup entries. - This module allows you to search for Zabbix hostgroup entries.
- This module was called C(zabbix_group_facts) before Ansible 2.9. The usage did not change.
version_added: "2.6" version_added: "2.6"
author: author:
- "Michael Miko (@RedWhiteMiko)" - "Michael Miko (@RedWhiteMiko)"
@ -46,7 +47,7 @@ extends_documentation_fragment:
EXAMPLES = ''' EXAMPLES = '''
- name: Get hostgroup info - name: Get hostgroup info
local_action: local_action:
module: zabbix_group_facts module: zabbix_group_info
server_url: http://monitor.example.com server_url: http://monitor.example.com
login_user: username login_user: username
login_password: password login_password: password
@ -102,6 +103,8 @@ def main():
), ),
supports_check_mode=True supports_check_mode=True
) )
if module._name == 'zabbix_group_facts':
module.deprecate("The 'zabbix_group_facts' module has been renamed to 'zabbix_group_info'", version='2.13')
if not HAS_ZABBIX_API: if not HAS_ZABBIX_API:
module.fail_json(msg="Missing required zabbix-api module (check docs or install with: pip install zabbix-api)") module.fail_json(msg="Missing required zabbix-api module (check docs or install with: pip install zabbix-api)")

View file

@ -24,10 +24,11 @@ hosts:
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: zabbix_host_facts module: zabbix_host_info
short_description: Gather facts about Zabbix host short_description: Gather information about Zabbix host
description: description:
- This module allows you to search for Zabbix host entries. - This module allows you to search for Zabbix host entries.
- This module was called C(zabbix_host_facts) before Ansible 2.9. The usage did not change.
version_added: "2.7" version_added: "2.7"
author: author:
- "Michael Miko (@RedWhiteMiko)" - "Michael Miko (@RedWhiteMiko)"
@ -68,7 +69,7 @@ extends_documentation_fragment:
EXAMPLES = ''' EXAMPLES = '''
- name: Get host info - name: Get host info
local_action: local_action:
module: zabbix_host_facts module: zabbix_host_info
server_url: http://monitor.example.com server_url: http://monitor.example.com
login_user: username login_user: username
login_password: password login_password: password
@ -80,7 +81,7 @@ EXAMPLES = '''
- name: Reduce host inventory information to provided keys - name: Reduce host inventory information to provided keys
local_action: local_action:
module: zabbix_host_facts module: zabbix_host_info
server_url: http://monitor.example.com server_url: http://monitor.example.com
login_user: username login_user: username
login_password: password login_password: password
@ -185,6 +186,8 @@ def main():
), ),
supports_check_mode=True supports_check_mode=True
) )
if module._name == 'zabbix_host_facts':
module.deprecate("The 'zabbix_host_facts' module has been renamed to 'zabbix_host_info'", version='2.13')
if not HAS_ZABBIX_API: if not HAS_ZABBIX_API:
module.fail_json(msg="Missing required zabbix-api module (check docs or install with: pip install zabbix-api)") module.fail_json(msg="Missing required zabbix-api module (check docs or install with: pip install zabbix-api)")

View file

@ -0,0 +1 @@
python_requirements_info.py

View file

@ -12,10 +12,11 @@ ANSIBLE_METADATA = {
} }
DOCUMENTATION = ''' DOCUMENTATION = '''
module: python_requirements_facts module: python_requirements_info
short_description: Show python path and assert dependency versions short_description: Show python path and assert dependency versions
description: description:
- Get info about available Python requirements on the target host, including listing required libraries and gathering versions. - Get info about available Python requirements on the target host, including listing required libraries and gathering versions.
- This module was called C(python_requirements_facts) before Ansible 2.9. The usage did not change.
version_added: "2.7" version_added: "2.7"
options: options:
dependencies: dependencies:
@ -31,9 +32,9 @@ author:
EXAMPLES = ''' EXAMPLES = '''
- name: show python lib/site paths - name: show python lib/site paths
python_requirements_facts: python_requirements_info:
- name: check for modern boto3 and botocore versions - name: check for modern boto3 and botocore versions
python_requirements_facts: python_requirements_info:
dependencies: dependencies:
- boto3>1.6 - boto3>1.6
- botocore<2 - botocore<2
@ -116,6 +117,8 @@ def main():
), ),
supports_check_mode=True, supports_check_mode=True,
) )
if module._name == 'python_requirements_facts':
module.deprecate("The 'python_requirements_facts' module has been renamed to 'python_requirements_info'", version='2.13')
if not HAS_DISTUTILS: if not HAS_DISTUTILS:
module.fail_json( module.fail_json(
msg='Could not import "distutils" and "pkg_resources" libraries to introspect python environment.', msg='Could not import "distutils" and "pkg_resources" libraries to introspect python environment.',

View file

@ -17,18 +17,18 @@
debug: debug:
var: output var: output
- name: k8s_facts works with empty resources - name: k8s_info works with empty resources
k8s_facts: k8s_info:
kind: Deployment kind: Deployment
namespace: testing namespace: testing
api_version: extensions/v1beta1 api_version: extensions/v1beta1
register: k8s_facts register: k8s_info
- name: assert that k8s_facts is in correct format - name: assert that k8s_info is in correct format
assert: assert:
that: that:
- "'resources' in k8s_facts" - "'resources' in k8s_info"
- not k8s_facts.resources - not k8s_info.resources
- name: Create a service - name: Create a service
k8s: k8s:
@ -162,12 +162,12 @@
name: testing1 name: testing1
- name: Namespace should exist - name: Namespace should exist
k8s_facts: k8s_info:
kind: Namespace kind: Namespace
api_version: v1 api_version: v1
name: testing1 name: testing1
register: k8s_facts_testing1 register: k8s_info_testing1
failed_when: not k8s_facts_testing1.resources or k8s_facts_testing1.resources[0].status.phase != "Active" failed_when: not k8s_info_testing1.resources or k8s_info_testing1.resources[0].status.phase != "Active"
- name: Create resources from a multidocument yaml string - name: Create resources from a multidocument yaml string
k8s: k8s:
@ -184,7 +184,7 @@
name: testing3 name: testing3
- name: Lookup namespaces - name: Lookup namespaces
k8s_facts: k8s_info:
api_version: v1 api_version: v1
kind: Namespace kind: Namespace
name: "{{ item }}" name: "{{ item }}"
@ -214,7 +214,7 @@
name: testing3 name: testing3
- name: Lookup namespaces - name: Lookup namespaces
k8s_facts: k8s_info:
api_version: v1 api_version: v1
kind: Namespace kind: Namespace
name: "{{ item }}" name: "{{ item }}"
@ -242,7 +242,7 @@
name: testing5 name: testing5
- name: Lookup namespaces - name: Lookup namespaces
k8s_facts: k8s_info:
api_version: v1 api_version: v1
kind: Namespace kind: Namespace
name: "{{ item }}" name: "{{ item }}"
@ -269,20 +269,20 @@
metadata: metadata:
name: testing5 name: testing5
- k8s_facts: - k8s_info:
api_version: v1 api_version: v1
kind: Namespace kind: Namespace
name: "{{ item }}" name: "{{ item }}"
loop: loop:
- testing4 - testing4
- testing5 - testing5
register: k8s_facts register: k8s_info
- name: Resources are terminating if still in results - name: Resources are terminating if still in results
assert: assert:
that: not item.resources or item.resources[0].status.phase == "Terminating" that: not item.resources or item.resources[0].status.phase == "Terminating"
loop: "{{ k8s_facts.results }}" loop: "{{ k8s_info.results }}"
- include_tasks: crd.yml - include_tasks: crd.yml
- include_tasks: lists.yml - include_tasks: lists.yml

View file

@ -16,7 +16,7 @@
items: '{{ configmaps }}' items: '{{ configmaps }}'
- name: Get ConfigMaps - name: Get ConfigMaps
k8s_facts: k8s_info:
api_version: v1 api_version: v1
kind: ConfigMap kind: ConfigMap
namespace: testing1 namespace: testing1
@ -39,7 +39,7 @@
items: '{{ configmaps }}' items: '{{ configmaps }}'
- name: Get ConfigMaps - name: Get ConfigMaps
k8s_facts: k8s_info:
api_version: v1 api_version: v1
kind: ConfigMap kind: ConfigMap
namespace: testing1 namespace: testing1
@ -82,7 +82,7 @@
items: '{{ resources }}' items: '{{ resources }}'
- name: Get the created resources - name: Get the created resources
k8s_facts: k8s_info:
api_version: '{{ item.apiVersion }}' api_version: '{{ item.apiVersion }}'
kind: '{{ item.kind }}' kind: '{{ item.kind }}'
namespace: testing1 namespace: testing1
@ -105,7 +105,7 @@
items: '{{ resources }}' items: '{{ resources }}'
- name: Get the resources - name: Get the resources
k8s_facts: k8s_info:
api_version: '{{ item.apiVersion }}' api_version: '{{ item.apiVersion }}'
kind: '{{ item.kind }}' kind: '{{ item.kind }}'
namespace: testing1 namespace: testing1

View file

@ -1,4 +1,4 @@
- python_requirements_facts: - python_requirements_info:
dependencies: dependencies:
- openshift==0.6.0 - openshift==0.6.0
- kubernetes==6.0.0 - kubernetes==6.0.0

View file

@ -1,5 +1,5 @@
- name: ensure that there are actually some nodes - name: ensure that there are actually some nodes
k8s_facts: k8s_info:
kind: Node kind: Node
register: nodes register: nodes
@ -113,7 +113,7 @@
register: ds register: ds
- name: get updated pods - name: get updated pods
k8s_facts: k8s_info:
api_version: v1 api_version: v1
kind: Pod kind: Pod
namespace: "{{ wait_namespace }}" namespace: "{{ wait_namespace }}"
@ -228,7 +228,7 @@
register: update_deploy register: update_deploy
- name: get updated pods - name: get updated pods
k8s_facts: k8s_info:
api_version: v1 api_version: v1
kind: Pod kind: Pod
namespace: "{{ wait_namespace }}" namespace: "{{ wait_namespace }}"

View file

@ -1,22 +0,0 @@
- name: run python_requirements_facts module
python_requirements_facts:
register: basic_facts
- name: ensure python_requirements_facts returns desired info
assert:
that:
- "'python' in basic_facts"
- "'python_version' in basic_facts"
- name: run python_requirements_facts module
python_requirements_facts:
dependencies:
- notreal<1
- ansible>2
register: dep_facts
- name: ensure python_requirements_facts returns desired info
assert:
that:
- "'installed' in dep_facts.valid.ansible"
- "'notreal' in dep_facts.not_found"

View file

@ -0,0 +1,22 @@
- name: run python_requirements_info module
python_requirements_info:
register: basic_info
- name: ensure python_requirements_info returns desired info
assert:
that:
- "'python' in basic_info"
- "'python_version' in basic_info"
- name: run python_requirements_info module
python_requirements_info:
dependencies:
- notreal<1
- ansible>2
register: dep_info
- name: ensure python_requirements_info returns desired info
assert:
that:
- "'installed' in dep_info.valid.ansible"
- "'notreal' in dep_info.not_found"