From 7a0af34ba9f9c7038988248b213ab887a2bc814b Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Mon, 27 May 2019 18:17:42 +0200 Subject: [PATCH] First batch _facts -> _info rename. (#56822) --- .../fragments/56822-facts-info-rename.yaml | 5 ++++ .../rst/porting_guides/porting_guide_2.9.rst | 5 ++++ .../modules/clustering/k8s/_k8s_facts.py | 1 + lib/ansible/modules/clustering/k8s/k8s.py | 2 +- .../modules/clustering/k8s/k8s_auth.py | 2 +- .../k8s/{k8s_facts.py => k8s_info.py} | 19 +++++++----- .../monitoring/zabbix/_zabbix_group_facts.py | 1 + .../monitoring/zabbix/_zabbix_host_facts.py | 1 + ...ix_group_facts.py => zabbix_group_info.py} | 9 ++++-- ...bbix_host_facts.py => zabbix_host_info.py} | 11 ++++--- .../system/_python_requirements_facts.py | 1 + ...s_facts.py => python_requirements_info.py} | 9 ++++-- .../targets/k8s/tasks/full_test.yml | 30 +++++++++---------- test/integration/targets/k8s/tasks/lists.yml | 8 ++--- .../k8s/tasks/older_openshift_fail.yml | 2 +- test/integration/targets/k8s/tasks/waiter.yml | 6 ++-- .../python_requirements_facts/tasks/main.yml | 22 -------------- .../aliases | 0 .../python_requirements_info/tasks/main.yml | 22 ++++++++++++++ 19 files changed, 91 insertions(+), 65 deletions(-) create mode 100644 changelogs/fragments/56822-facts-info-rename.yaml create mode 120000 lib/ansible/modules/clustering/k8s/_k8s_facts.py rename lib/ansible/modules/clustering/k8s/{k8s_facts.py => k8s_info.py} (92%) create mode 120000 lib/ansible/modules/monitoring/zabbix/_zabbix_group_facts.py create mode 120000 lib/ansible/modules/monitoring/zabbix/_zabbix_host_facts.py rename lib/ansible/modules/monitoring/zabbix/{zabbix_group_facts.py => zabbix_group_info.py} (92%) rename lib/ansible/modules/monitoring/zabbix/{zabbix_host_facts.py => zabbix_host_info.py} (95%) create mode 120000 lib/ansible/modules/system/_python_requirements_facts.py rename lib/ansible/modules/system/{python_requirements_facts.py => python_requirements_info.py} (92%) delete mode 100644 test/integration/targets/python_requirements_facts/tasks/main.yml rename test/integration/targets/{python_requirements_facts => python_requirements_info}/aliases (100%) create mode 100644 test/integration/targets/python_requirements_info/tasks/main.yml diff --git a/changelogs/fragments/56822-facts-info-rename.yaml b/changelogs/fragments/56822-facts-info-rename.yaml new file mode 100644 index 00000000000..0fde9a0b1ea --- /dev/null +++ b/changelogs/fragments/56822-facts-info-rename.yaml @@ -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``. diff --git a/docs/docsite/rst/porting_guides/porting_guide_2.9.rst b/docs/docsite/rst/porting_guides/porting_guide_2.9.rst index 3ae6550bfad..92fa92f9918 100644 --- a/docs/docsite/rst/porting_guides/porting_guide_2.9.rst +++ b/docs/docsite/rst/porting_guides/porting_guide_2.9.rst @@ -69,6 +69,11 @@ Noteworthy module changes * `vmware_dvswitch ` accepts `folder` parameter to place dvswitch in user defined folder. This option makes `datacenter` as an optional parameter. * `vmware_datastore_cluster ` 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 `. +* The ``zabbix_group_facts`` module was renamed to :ref:`zabbix_group_info `. +* The ``zabbix_host_facts`` module was renamed to :ref:`zabbix_host_info `. +* The ``k8s_facts`` module was renamed to :ref:`k8s_info `. + Plugins ======= diff --git a/lib/ansible/modules/clustering/k8s/_k8s_facts.py b/lib/ansible/modules/clustering/k8s/_k8s_facts.py new file mode 120000 index 00000000000..667980ed38a --- /dev/null +++ b/lib/ansible/modules/clustering/k8s/_k8s_facts.py @@ -0,0 +1 @@ +k8s_info.py \ No newline at end of file diff --git a/lib/ansible/modules/clustering/k8s/k8s.py b/lib/ansible/modules/clustering/k8s/k8s.py index 8ccfbb37624..8d560b9bd27 100644 --- a/lib/ansible/modules/clustering/k8s/k8s.py +++ b/lib/ansible/modules/clustering/k8s/k8s.py @@ -30,7 +30,7 @@ description: - Pass the object definition from a source file or inline. See examples for reading files and using Jinja templates or vault-encrypted files. - 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. - Supports check mode. diff --git a/lib/ansible/modules/clustering/k8s/k8s_auth.py b/lib/ansible/modules/clustering/k8s/k8s_auth.py index b1ea7c23862..8dfd2efcb67 100644 --- a/lib/ansible/modules/clustering/k8s/k8s_auth.py +++ b/lib/ansible/modules/clustering/k8s/k8s_auth.py @@ -96,7 +96,7 @@ EXAMPLES = ''' # Previous task provides the token/api_key, while all other parameters # are taken from module_defaults - name: Get a list of all pods from any namespace - k8s_facts: + k8s_info: api_key: "{{ k8s_auth_results.k8s_auth.api_key }}" kind: Pod register: pod_list diff --git a/lib/ansible/modules/clustering/k8s/k8s_facts.py b/lib/ansible/modules/clustering/k8s/k8s_info.py similarity index 92% rename from lib/ansible/modules/clustering/k8s/k8s_facts.py rename to lib/ansible/modules/clustering/k8s/k8s_info.py index c87208faa15..ff9e96169d7 100644 --- a/lib/ansible/modules/clustering/k8s/k8s_facts.py +++ b/lib/ansible/modules/clustering/k8s/k8s_info.py @@ -14,7 +14,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', 'supported_by': 'community'} DOCUMENTATION = ''' -module: k8s_facts +module: k8s_info short_description: Describe Kubernetes (K8s) objects @@ -28,6 +28,7 @@ description: - Access to the full range of K8s APIs. - Authenticate using either a config file, certificates, password or token. - Supports check mode. + - This module was called C(k8s_facts) before Ansible 2.9. The usage did not change. options: api_version: @@ -67,7 +68,7 @@ requirements: EXAMPLES = ''' - name: Get an existing Service object - k8s_facts: + k8s_info: api_version: v1 kind: Service name: web @@ -75,26 +76,26 @@ EXAMPLES = ''' register: web_service - name: Get a list of all service objects - k8s_facts: + k8s_info: api_version: v1 kind: Service namespace: testing register: service_list - name: Get a list of all pods from any namespace - k8s_facts: + k8s_info: kind: Pod register: pod_list - name: Search for all Pods labelled app=web - k8s_facts: + k8s_info: kind: Pod label_selectors: - app = web - tier in (dev, test) - name: Search for all running pods - k8s_facts: + k8s_info: kind: Pod field_selectors: - status.phase=Running @@ -134,12 +135,14 @@ from ansible.module_utils.k8s.common import KubernetesAnsibleModule, AUTH_ARG_SP import copy -class KubernetesFactsModule(KubernetesAnsibleModule): +class KubernetesInfoModule(KubernetesAnsibleModule): def __init__(self, *args, **kwargs): KubernetesAnsibleModule.__init__(self, *args, supports_check_mode=True, **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): self.client = self.get_api_client() @@ -169,7 +172,7 @@ class KubernetesFactsModule(KubernetesAnsibleModule): def main(): - KubernetesFactsModule().execute_module() + KubernetesInfoModule().execute_module() if __name__ == '__main__': diff --git a/lib/ansible/modules/monitoring/zabbix/_zabbix_group_facts.py b/lib/ansible/modules/monitoring/zabbix/_zabbix_group_facts.py new file mode 120000 index 00000000000..20451bef688 --- /dev/null +++ b/lib/ansible/modules/monitoring/zabbix/_zabbix_group_facts.py @@ -0,0 +1 @@ +zabbix_group_info.py \ No newline at end of file diff --git a/lib/ansible/modules/monitoring/zabbix/_zabbix_host_facts.py b/lib/ansible/modules/monitoring/zabbix/_zabbix_host_facts.py new file mode 120000 index 00000000000..c6d22f6237c --- /dev/null +++ b/lib/ansible/modules/monitoring/zabbix/_zabbix_host_facts.py @@ -0,0 +1 @@ +zabbix_host_info.py \ No newline at end of file diff --git a/lib/ansible/modules/monitoring/zabbix/zabbix_group_facts.py b/lib/ansible/modules/monitoring/zabbix/zabbix_group_info.py similarity index 92% rename from lib/ansible/modules/monitoring/zabbix/zabbix_group_facts.py rename to lib/ansible/modules/monitoring/zabbix/zabbix_group_info.py index 5607c7e60c6..579051122ad 100644 --- a/lib/ansible/modules/monitoring/zabbix/zabbix_group_facts.py +++ b/lib/ansible/modules/monitoring/zabbix/zabbix_group_info.py @@ -23,10 +23,11 @@ host_groups: DOCUMENTATION = ''' --- -module: zabbix_group_facts -short_description: Gather facts about Zabbix hostgroup +module: zabbix_group_info +short_description: Gather information about Zabbix hostgroup description: - 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" author: - "Michael Miko (@RedWhiteMiko)" @@ -46,7 +47,7 @@ extends_documentation_fragment: EXAMPLES = ''' - name: Get hostgroup info local_action: - module: zabbix_group_facts + module: zabbix_group_info server_url: http://monitor.example.com login_user: username login_password: password @@ -102,6 +103,8 @@ def main(): ), 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: module.fail_json(msg="Missing required zabbix-api module (check docs or install with: pip install zabbix-api)") diff --git a/lib/ansible/modules/monitoring/zabbix/zabbix_host_facts.py b/lib/ansible/modules/monitoring/zabbix/zabbix_host_info.py similarity index 95% rename from lib/ansible/modules/monitoring/zabbix/zabbix_host_facts.py rename to lib/ansible/modules/monitoring/zabbix/zabbix_host_info.py index 1ace8c8a073..0104311177c 100644 --- a/lib/ansible/modules/monitoring/zabbix/zabbix_host_facts.py +++ b/lib/ansible/modules/monitoring/zabbix/zabbix_host_info.py @@ -24,10 +24,11 @@ hosts: DOCUMENTATION = ''' --- -module: zabbix_host_facts -short_description: Gather facts about Zabbix host +module: zabbix_host_info +short_description: Gather information about Zabbix host description: - 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" author: - "Michael Miko (@RedWhiteMiko)" @@ -68,7 +69,7 @@ extends_documentation_fragment: EXAMPLES = ''' - name: Get host info local_action: - module: zabbix_host_facts + module: zabbix_host_info server_url: http://monitor.example.com login_user: username login_password: password @@ -80,7 +81,7 @@ EXAMPLES = ''' - name: Reduce host inventory information to provided keys local_action: - module: zabbix_host_facts + module: zabbix_host_info server_url: http://monitor.example.com login_user: username login_password: password @@ -185,6 +186,8 @@ def main(): ), 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: module.fail_json(msg="Missing required zabbix-api module (check docs or install with: pip install zabbix-api)") diff --git a/lib/ansible/modules/system/_python_requirements_facts.py b/lib/ansible/modules/system/_python_requirements_facts.py new file mode 120000 index 00000000000..d8168290345 --- /dev/null +++ b/lib/ansible/modules/system/_python_requirements_facts.py @@ -0,0 +1 @@ +python_requirements_info.py \ No newline at end of file diff --git a/lib/ansible/modules/system/python_requirements_facts.py b/lib/ansible/modules/system/python_requirements_info.py similarity index 92% rename from lib/ansible/modules/system/python_requirements_facts.py rename to lib/ansible/modules/system/python_requirements_info.py index 9048758bd7b..d381a064199 100644 --- a/lib/ansible/modules/system/python_requirements_facts.py +++ b/lib/ansible/modules/system/python_requirements_info.py @@ -12,10 +12,11 @@ ANSIBLE_METADATA = { } DOCUMENTATION = ''' -module: python_requirements_facts +module: python_requirements_info short_description: Show python path and assert dependency versions description: - 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" options: dependencies: @@ -31,9 +32,9 @@ author: EXAMPLES = ''' - name: show python lib/site paths - python_requirements_facts: + python_requirements_info: - name: check for modern boto3 and botocore versions - python_requirements_facts: + python_requirements_info: dependencies: - boto3>1.6 - botocore<2 @@ -116,6 +117,8 @@ def main(): ), 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: module.fail_json( msg='Could not import "distutils" and "pkg_resources" libraries to introspect python environment.', diff --git a/test/integration/targets/k8s/tasks/full_test.yml b/test/integration/targets/k8s/tasks/full_test.yml index de936660a1c..804a0d87ba7 100644 --- a/test/integration/targets/k8s/tasks/full_test.yml +++ b/test/integration/targets/k8s/tasks/full_test.yml @@ -17,18 +17,18 @@ debug: var: output - - name: k8s_facts works with empty resources - k8s_facts: + - name: k8s_info works with empty resources + k8s_info: kind: Deployment namespace: testing 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: that: - - "'resources' in k8s_facts" - - not k8s_facts.resources + - "'resources' in k8s_info" + - not k8s_info.resources - name: Create a service k8s: @@ -162,12 +162,12 @@ name: testing1 - name: Namespace should exist - k8s_facts: + k8s_info: kind: Namespace api_version: v1 name: testing1 - register: k8s_facts_testing1 - failed_when: not k8s_facts_testing1.resources or k8s_facts_testing1.resources[0].status.phase != "Active" + register: k8s_info_testing1 + failed_when: not k8s_info_testing1.resources or k8s_info_testing1.resources[0].status.phase != "Active" - name: Create resources from a multidocument yaml string k8s: @@ -184,7 +184,7 @@ name: testing3 - name: Lookup namespaces - k8s_facts: + k8s_info: api_version: v1 kind: Namespace name: "{{ item }}" @@ -214,7 +214,7 @@ name: testing3 - name: Lookup namespaces - k8s_facts: + k8s_info: api_version: v1 kind: Namespace name: "{{ item }}" @@ -242,7 +242,7 @@ name: testing5 - name: Lookup namespaces - k8s_facts: + k8s_info: api_version: v1 kind: Namespace name: "{{ item }}" @@ -269,20 +269,20 @@ metadata: name: testing5 - - k8s_facts: + - k8s_info: api_version: v1 kind: Namespace name: "{{ item }}" loop: - testing4 - testing5 - register: k8s_facts + register: k8s_info - name: Resources are terminating if still in results assert: 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: lists.yml diff --git a/test/integration/targets/k8s/tasks/lists.yml b/test/integration/targets/k8s/tasks/lists.yml index dfdc53301b4..4d464df734f 100644 --- a/test/integration/targets/k8s/tasks/lists.yml +++ b/test/integration/targets/k8s/tasks/lists.yml @@ -16,7 +16,7 @@ items: '{{ configmaps }}' - name: Get ConfigMaps - k8s_facts: + k8s_info: api_version: v1 kind: ConfigMap namespace: testing1 @@ -39,7 +39,7 @@ items: '{{ configmaps }}' - name: Get ConfigMaps - k8s_facts: + k8s_info: api_version: v1 kind: ConfigMap namespace: testing1 @@ -82,7 +82,7 @@ items: '{{ resources }}' - name: Get the created resources - k8s_facts: + k8s_info: api_version: '{{ item.apiVersion }}' kind: '{{ item.kind }}' namespace: testing1 @@ -105,7 +105,7 @@ items: '{{ resources }}' - name: Get the resources - k8s_facts: + k8s_info: api_version: '{{ item.apiVersion }}' kind: '{{ item.kind }}' namespace: testing1 diff --git a/test/integration/targets/k8s/tasks/older_openshift_fail.yml b/test/integration/targets/k8s/tasks/older_openshift_fail.yml index 85fa9878dbd..aa9afc0a864 100644 --- a/test/integration/targets/k8s/tasks/older_openshift_fail.yml +++ b/test/integration/targets/k8s/tasks/older_openshift_fail.yml @@ -1,4 +1,4 @@ - - python_requirements_facts: + - python_requirements_info: dependencies: - openshift==0.6.0 - kubernetes==6.0.0 diff --git a/test/integration/targets/k8s/tasks/waiter.yml b/test/integration/targets/k8s/tasks/waiter.yml index af29943b208..b6e64488daa 100644 --- a/test/integration/targets/k8s/tasks/waiter.yml +++ b/test/integration/targets/k8s/tasks/waiter.yml @@ -1,5 +1,5 @@ - name: ensure that there are actually some nodes - k8s_facts: + k8s_info: kind: Node register: nodes @@ -113,7 +113,7 @@ register: ds - name: get updated pods - k8s_facts: + k8s_info: api_version: v1 kind: Pod namespace: "{{ wait_namespace }}" @@ -228,7 +228,7 @@ register: update_deploy - name: get updated pods - k8s_facts: + k8s_info: api_version: v1 kind: Pod namespace: "{{ wait_namespace }}" diff --git a/test/integration/targets/python_requirements_facts/tasks/main.yml b/test/integration/targets/python_requirements_facts/tasks/main.yml deleted file mode 100644 index 1eeab872a5e..00000000000 --- a/test/integration/targets/python_requirements_facts/tasks/main.yml +++ /dev/null @@ -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" diff --git a/test/integration/targets/python_requirements_facts/aliases b/test/integration/targets/python_requirements_info/aliases similarity index 100% rename from test/integration/targets/python_requirements_facts/aliases rename to test/integration/targets/python_requirements_info/aliases diff --git a/test/integration/targets/python_requirements_info/tasks/main.yml b/test/integration/targets/python_requirements_info/tasks/main.yml new file mode 100644 index 00000000000..9ef340513a5 --- /dev/null +++ b/test/integration/targets/python_requirements_info/tasks/main.yml @@ -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"