From 1a59247f279d6ae8e3e5080da37bcb9909cf47de Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Tue, 19 Dec 2017 16:25:33 -0500 Subject: [PATCH] K8s raw modules (#34050) * New dirs, raw modules, and deprecations, 'openshift' not 'oc' --- lib/ansible/modules/clustering/k8s/__init__.py | 0 .../{kubernetes.py => k8s/_kubernetes.py} | 3 ++- .../clustering/{k8s.py => k8s/k8s_raw.py} | 14 +++++++------- .../modules/clustering/openshift/__init__.py | 0 .../clustering/{oc.py => openshift/_oc.py} | 9 +++++---- .../openshift_raw.py} | 18 +++++++++--------- 6 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 lib/ansible/modules/clustering/k8s/__init__.py rename lib/ansible/modules/clustering/{kubernetes.py => k8s/_kubernetes.py} (99%) rename lib/ansible/modules/clustering/{k8s.py => k8s/k8s_raw.py} (97%) create mode 100644 lib/ansible/modules/clustering/openshift/__init__.py rename lib/ansible/modules/clustering/{oc.py => openshift/_oc.py} (98%) rename lib/ansible/modules/clustering/{openshift.py => openshift/openshift_raw.py} (96%) diff --git a/lib/ansible/modules/clustering/k8s/__init__.py b/lib/ansible/modules/clustering/k8s/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/ansible/modules/clustering/kubernetes.py b/lib/ansible/modules/clustering/k8s/_kubernetes.py similarity index 99% rename from lib/ansible/modules/clustering/kubernetes.py rename to lib/ansible/modules/clustering/k8s/_kubernetes.py index d92ac810fd..4106399482 100755 --- a/lib/ansible/modules/clustering/kubernetes.py +++ b/lib/ansible/modules/clustering/k8s/_kubernetes.py @@ -7,13 +7,14 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', - 'status': ['preview'], + 'status': ['deprecated'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: kubernetes version_added: "2.1" +deprecated: In 2.5 use M(k8s_raw) instead. short_description: Manage Kubernetes resources description: - This module can manage Kubernetes resources on an existing cluster using diff --git a/lib/ansible/modules/clustering/k8s.py b/lib/ansible/modules/clustering/k8s/k8s_raw.py similarity index 97% rename from lib/ansible/modules/clustering/k8s.py rename to lib/ansible/modules/clustering/k8s/k8s_raw.py index f145bde171..26378e5605 100644 --- a/lib/ansible/modules/clustering/k8s.py +++ b/lib/ansible/modules/clustering/k8s/k8s_raw.py @@ -15,7 +15,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', DOCUMENTATION = ''' -module: k8s +module: k8s_raw short_description: Manage Kubernetes (K8s) objects @@ -38,14 +38,14 @@ requirements: EXAMPLES = ''' - name: Create a k8s namespace - k8s: + k8s_raw: name: testing api_version: v1 kind: Namespace state: present - name: Create a Service object from an inline definition - k8s: + k8s_raw: state: present definition: apiVersion: v1 @@ -67,12 +67,12 @@ EXAMPLES = ''' port: 8000 - name: Create a Service object by reading the definition from a file - k8s: + k8s_raw: state: present src: /testing/service.yml - name: Get an existing Service object - k8s: + k8s_raw: api_version: v1 kind: Service name: web @@ -80,14 +80,14 @@ EXAMPLES = ''' register: web_service - name: Get a list of all service objects - k8s: + k8s_raw: api_version: v1 kind: ServiceList namespace: testing register: service_list - name: Remove an existing Service object - k8s: + k8s_raw: state: absent api_version: v1 kind: Service diff --git a/lib/ansible/modules/clustering/openshift/__init__.py b/lib/ansible/modules/clustering/openshift/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/ansible/modules/clustering/oc.py b/lib/ansible/modules/clustering/openshift/_oc.py similarity index 98% rename from lib/ansible/modules/clustering/oc.py rename to lib/ansible/modules/clustering/openshift/_oc.py index 0fdae9dcb8..45fa4c3bd3 100644 --- a/lib/ansible/modules/clustering/oc.py +++ b/lib/ansible/modules/clustering/openshift/_oc.py @@ -9,7 +9,7 @@ __metaclass__ = type ANSIBLE_METADATA = { 'metadata_version': '1.1', - 'status': ['preview'], + 'status': ['deprecated'], 'supported_by': 'community' } @@ -17,6 +17,7 @@ ANSIBLE_METADATA = { DOCUMENTATION = """ author: - "Kenneth D. Evensen (@kevensen)" +deprecated: In 2.5 use M(openshift_raw) instead. description: - This module allows management of resources in an OpenShift cluster. The inventory host can be any host with network connectivity to the OpenShift @@ -245,7 +246,7 @@ class OC(object): return response, changed def exists(self, named_resource): - _, code = self.connect(named_resource.url(), 'get') + x, code = self.connect(named_resource.url(), 'get') if code == 200: return True return False @@ -285,7 +286,7 @@ class OC(object): def replace(self, named_resource, check_mode): changed = False - existing_definition, _ = self.get(named_resource) + existing_definition, x = self.get(named_resource) new_definition, changed = self.merge(named_resource.definition, existing_definition, @@ -344,7 +345,7 @@ class OC(object): except AttributeError: node = {} finally: - _, changed = self.merge(value, node, changed) + x, changed = self.merge(value, node, changed) elif isinstance(value, list) and key in destination.keys(): if destination[key] != source[key]: diff --git a/lib/ansible/modules/clustering/openshift.py b/lib/ansible/modules/clustering/openshift/openshift_raw.py similarity index 96% rename from lib/ansible/modules/clustering/openshift.py rename to lib/ansible/modules/clustering/openshift/openshift_raw.py index 22ab102dcc..a0d75d3787 100644 --- a/lib/ansible/modules/clustering/openshift.py +++ b/lib/ansible/modules/clustering/openshift/openshift_raw.py @@ -15,7 +15,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1', DOCUMENTATION = ''' -module: openshift +module: openshift_raw short_description: Manage OpenShift objects @@ -37,7 +37,7 @@ requirements: EXAMPLES = ''' - name: Create a project - openshift: + openshift_raw: api_version: v1 kind: Project name: testing @@ -46,7 +46,7 @@ EXAMPLES = ''' state: present - name: Create a Persistent Volume Claim from an inline definition - openshift: + openshift_raw: state: present definition: apiVersion: v1 @@ -62,7 +62,7 @@ EXAMPLES = ''' - ReadWriteOnce - name: Create a Deployment from an inline definition - openshift: + openshift_raw: state: present definition: apiVersion: v1 @@ -96,19 +96,19 @@ EXAMPLES = ''' type: Rolling - name: Create a Deployment by reading the definition from a file - openshift: + openshift_raw: state: present src: /testing/deployment.yml - name: Get the list of all Deployments - openshift: + openshift_raw: api_version: v1 kind: DeploymentConfigList namespace: testing register: deployment_list - name: Remove an existing Deployment - openshift: + openshift_raw: api_version: v1 kind: DeploymentConfig name: elastic @@ -116,7 +116,7 @@ EXAMPLES = ''' state: absent - name: Create a Secret - openshift: + openshift_raw: inline: apiVersion: v1 kind: Secret @@ -129,7 +129,7 @@ EXAMPLES = ''' password: "{{ 'foobard' | b64encode }}" - name: Retrieve the Secret - openshift: + openshift_raw: api: v1 kind: Secret name: mysecret