K8s raw modules (#34050)

* New dirs, raw modules, and deprecations, 'openshift' not 'oc'
This commit is contained in:
Chris Houseknecht 2017-12-19 16:25:33 -05:00 committed by Adam Miller
parent fcc79de246
commit 1a59247f27
6 changed files with 23 additions and 21 deletions

View file

@ -7,13 +7,14 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'], 'status': ['deprecated'],
'supported_by': 'community'} 'supported_by': 'community'}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: kubernetes module: kubernetes
version_added: "2.1" version_added: "2.1"
deprecated: In 2.5 use M(k8s_raw) instead.
short_description: Manage Kubernetes resources short_description: Manage Kubernetes resources
description: description:
- This module can manage Kubernetes resources on an existing cluster using - This module can manage Kubernetes resources on an existing cluster using

View file

@ -15,7 +15,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = ''' DOCUMENTATION = '''
module: k8s module: k8s_raw
short_description: Manage Kubernetes (K8s) objects short_description: Manage Kubernetes (K8s) objects
@ -38,14 +38,14 @@ requirements:
EXAMPLES = ''' EXAMPLES = '''
- name: Create a k8s namespace - name: Create a k8s namespace
k8s: k8s_raw:
name: testing name: testing
api_version: v1 api_version: v1
kind: Namespace kind: Namespace
state: present state: present
- name: Create a Service object from an inline definition - name: Create a Service object from an inline definition
k8s: k8s_raw:
state: present state: present
definition: definition:
apiVersion: v1 apiVersion: v1
@ -67,12 +67,12 @@ EXAMPLES = '''
port: 8000 port: 8000
- name: Create a Service object by reading the definition from a file - name: Create a Service object by reading the definition from a file
k8s: k8s_raw:
state: present state: present
src: /testing/service.yml src: /testing/service.yml
- name: Get an existing Service object - name: Get an existing Service object
k8s: k8s_raw:
api_version: v1 api_version: v1
kind: Service kind: Service
name: web name: web
@ -80,14 +80,14 @@ EXAMPLES = '''
register: web_service register: web_service
- name: Get a list of all service objects - name: Get a list of all service objects
k8s: k8s_raw:
api_version: v1 api_version: v1
kind: ServiceList kind: ServiceList
namespace: testing namespace: testing
register: service_list register: service_list
- name: Remove an existing Service object - name: Remove an existing Service object
k8s: k8s_raw:
state: absent state: absent
api_version: v1 api_version: v1
kind: Service kind: Service

View file

@ -9,7 +9,7 @@ __metaclass__ = type
ANSIBLE_METADATA = { ANSIBLE_METADATA = {
'metadata_version': '1.1', 'metadata_version': '1.1',
'status': ['preview'], 'status': ['deprecated'],
'supported_by': 'community' 'supported_by': 'community'
} }
@ -17,6 +17,7 @@ ANSIBLE_METADATA = {
DOCUMENTATION = """ DOCUMENTATION = """
author: author:
- "Kenneth D. Evensen (@kevensen)" - "Kenneth D. Evensen (@kevensen)"
deprecated: In 2.5 use M(openshift_raw) instead.
description: description:
- This module allows management of resources in an OpenShift cluster. The - This module allows management of resources in an OpenShift cluster. The
inventory host can be any host with network connectivity to the OpenShift inventory host can be any host with network connectivity to the OpenShift
@ -245,7 +246,7 @@ class OC(object):
return response, changed return response, changed
def exists(self, named_resource): def exists(self, named_resource):
_, code = self.connect(named_resource.url(), 'get') x, code = self.connect(named_resource.url(), 'get')
if code == 200: if code == 200:
return True return True
return False return False
@ -285,7 +286,7 @@ class OC(object):
def replace(self, named_resource, check_mode): def replace(self, named_resource, check_mode):
changed = False changed = False
existing_definition, _ = self.get(named_resource) existing_definition, x = self.get(named_resource)
new_definition, changed = self.merge(named_resource.definition, new_definition, changed = self.merge(named_resource.definition,
existing_definition, existing_definition,
@ -344,7 +345,7 @@ class OC(object):
except AttributeError: except AttributeError:
node = {} node = {}
finally: finally:
_, changed = self.merge(value, node, changed) x, changed = self.merge(value, node, changed)
elif isinstance(value, list) and key in destination.keys(): elif isinstance(value, list) and key in destination.keys():
if destination[key] != source[key]: if destination[key] != source[key]:

View file

@ -15,7 +15,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
DOCUMENTATION = ''' DOCUMENTATION = '''
module: openshift module: openshift_raw
short_description: Manage OpenShift objects short_description: Manage OpenShift objects
@ -37,7 +37,7 @@ requirements:
EXAMPLES = ''' EXAMPLES = '''
- name: Create a project - name: Create a project
openshift: openshift_raw:
api_version: v1 api_version: v1
kind: Project kind: Project
name: testing name: testing
@ -46,7 +46,7 @@ EXAMPLES = '''
state: present state: present
- name: Create a Persistent Volume Claim from an inline definition - name: Create a Persistent Volume Claim from an inline definition
openshift: openshift_raw:
state: present state: present
definition: definition:
apiVersion: v1 apiVersion: v1
@ -62,7 +62,7 @@ EXAMPLES = '''
- ReadWriteOnce - ReadWriteOnce
- name: Create a Deployment from an inline definition - name: Create a Deployment from an inline definition
openshift: openshift_raw:
state: present state: present
definition: definition:
apiVersion: v1 apiVersion: v1
@ -96,19 +96,19 @@ EXAMPLES = '''
type: Rolling type: Rolling
- name: Create a Deployment by reading the definition from a file - name: Create a Deployment by reading the definition from a file
openshift: openshift_raw:
state: present state: present
src: /testing/deployment.yml src: /testing/deployment.yml
- name: Get the list of all Deployments - name: Get the list of all Deployments
openshift: openshift_raw:
api_version: v1 api_version: v1
kind: DeploymentConfigList kind: DeploymentConfigList
namespace: testing namespace: testing
register: deployment_list register: deployment_list
- name: Remove an existing Deployment - name: Remove an existing Deployment
openshift: openshift_raw:
api_version: v1 api_version: v1
kind: DeploymentConfig kind: DeploymentConfig
name: elastic name: elastic
@ -116,7 +116,7 @@ EXAMPLES = '''
state: absent state: absent
- name: Create a Secret - name: Create a Secret
openshift: openshift_raw:
inline: inline:
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
@ -129,7 +129,7 @@ EXAMPLES = '''
password: "{{ 'foobard' | b64encode }}" password: "{{ 'foobard' | b64encode }}"
- name: Retrieve the Secret - name: Retrieve the Secret
openshift: openshift_raw:
api: v1 api: v1
kind: Secret kind: Secret
name: mysecret name: mysecret