summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/clustering/openshift
diff options
context:
space:
mode:
authorFabian von Feilitzsch <fabian@fabianism.us>2018-05-16 11:57:36 -0400
committerAdam Miller <admiller@redhat.com>2018-05-16 10:57:36 -0500
commit4373b155a58dc8268e6a54ca9d32000450b39fdb (patch)
tree06775cd3c250b8e6e5c651d0b92ba7cbe629bd98 /lib/ansible/modules/clustering/openshift
parent7929aed7afb396cd9057b4f9255d1660c27f7670 (diff)
downloadansible-4373b155a58dc8268e6a54ca9d32000450b39fdb.tar.gz
Move k8s modules to dynamic backend (#39632)
* Move k8s modules to dynamic backend
Diffstat (limited to 'lib/ansible/modules/clustering/openshift')
l---------lib/ansible/modules/clustering/openshift/_openshift_raw.py1
l---------lib/ansible/modules/clustering/openshift/_openshift_scale.py1
-rw-r--r--lib/ansible/modules/clustering/openshift/openshift_raw.py204
-rw-r--r--lib/ansible/modules/clustering/openshift/openshift_scale.py127
4 files changed, 2 insertions, 331 deletions
diff --git a/lib/ansible/modules/clustering/openshift/_openshift_raw.py b/lib/ansible/modules/clustering/openshift/_openshift_raw.py
new file mode 120000
index 0000000000..53f9af49a8
--- /dev/null
+++ b/lib/ansible/modules/clustering/openshift/_openshift_raw.py
@@ -0,0 +1 @@
+../k8s/k8s.py \ No newline at end of file
diff --git a/lib/ansible/modules/clustering/openshift/_openshift_scale.py b/lib/ansible/modules/clustering/openshift/_openshift_scale.py
new file mode 120000
index 0000000000..bfa5417ea0
--- /dev/null
+++ b/lib/ansible/modules/clustering/openshift/_openshift_scale.py
@@ -0,0 +1 @@
+../k8s/k8s_scale.py \ No newline at end of file
diff --git a/lib/ansible/modules/clustering/openshift/openshift_raw.py b/lib/ansible/modules/clustering/openshift/openshift_raw.py
deleted file mode 100644
index bf39917d11..0000000000
--- a/lib/ansible/modules/clustering/openshift/openshift_raw.py
+++ /dev/null
@@ -1,204 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# (c) 2018, Chris Houseknecht <@chouseknecht>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-
-ANSIBLE_METADATA = {'metadata_version': '1.1',
- 'status': ['preview'],
- 'supported_by': 'community'}
-
-DOCUMENTATION = '''
-
-module: openshift_raw
-
-short_description: Manage OpenShift objects
-
-version_added: "2.5"
-
-author: "Chris Houseknecht (@chouseknecht)"
-
-description:
- - Use the OpenShift Python client to perform CRUD operations on OpenShift objects.
- - Pass the object definition from a source file or inline. See examples for reading
- files and using Jinja templates.
- - Access to the full range of K8s and OpenShift APIs.
- - Authenticate using either a config file, certificates, password or token.
- - Supports check mode.
-
-extends_documentation_fragment:
- - k8s_state_options
- - k8s_name_options
- - k8s_resource_options
- - k8s_auth_options
-
-options:
- description:
- description:
- - Use only when creating a project, otherwise ignored. Adds a description to the project
- metadata.
- display_name:
- description:
- - Use only when creating a project, otherwise ignored. Adds a display name to the project
- metadata.
-
-requirements:
- - "python >= 2.7"
- - "openshift == 0.4.3"
- - "PyYAML >= 3.11"
-'''
-
-EXAMPLES = '''
-- name: Create a project
- openshift_raw:
- api_version: v1
- kind: Project
- name: testing
- description: Testing
- display_name: "This is a test project."
- state: present
-
-- name: Create a Persistent Volume Claim from an inline definition
- openshift_raw:
- state: present
- definition:
- apiVersion: v1
- kind: PersistentVolumeClaim
- metadata:
- name: elastic-volume
- namespace: testing
- spec:
- resources:
- requests:
- storage: 5Gi
- accessModes:
- - ReadWriteOnce
-
-- name: Create a Deployment from an inline definition
- openshift_raw:
- state: present
- definition:
- apiVersion: v1
- kind: DeploymentConfig
- metadata:
- name: elastic
- labels:
- app: galaxy
- service: elastic
- namespace: testing
- spec:
- template:
- metadata:
- labels:
- app: galaxy
- service: elastic
- spec:
- containers:
- - name: elastic
- volumeMounts:
- - mountPath: /usr/share/elasticsearch/data
- name: elastic-volume
- command: ["elasticsearch"]
- image: "ansible/galaxy-elasticsearch:2.4.6"
- volumes:
- - name: elastic-volume
- persistentVolumeClaim:
- claimName: elastic-volume
- replicas: 1
- strategy:
- type: Rolling
-
-- name: Remove an existing Deployment
- openshift_raw:
- api_version: v1
- kind: DeploymentConfig
- name: elastic
- namespace: testing
- state: absent
-
-- name: Create a Secret
- openshift_raw:
- definition:
- apiVersion: v1
- kind: Secret
- metadata:
- name: mysecret
- namespace: testing
- type: Opaque
- data:
- username: "{{ 'admin' | b64encode }}"
- password: "{{ 'foobard' | b64encode }}"
-
-- name: Retrieve a Secret
- openshift_raw:
- api: v1
- kind: Secret
- name: mysecret
- namespace: testing
- register: mysecret
-
-# Passing the object definition from a file
-
-- name: Create a Deployment by reading the definition from a local file
- openshift_raw:
- state: present
- src: /testing/deployment.yml
-
-- name: Read definition file from the Ansible controller file system
- openshift_raw:
- state: present
- definition: "{{ lookup('file', '/testing/deployment.yml') | from_yaml }}"
-
-- name: Read definition file from the Ansible controller file system after Jinja templating
- openshift_raw:
- state: present
- definition: "{{ lookup('template', '/testing/deployment.yml') | from_yaml }}"
-'''
-
-RETURN = '''
-result:
- description:
- - The created, patched, or otherwise present object. Will be empty in the case of a deletion.
- returned: success
- type: complex
- contains:
- api_version:
- description: The versioned schema of this representation of an object.
- returned: success
- type: str
- kind:
- description: Represents the REST resource this object represents.
- returned: success
- type: str
- metadata:
- description: Standard object metadata. Includes name, namespace, annotations, labels, etc.
- returned: success
- type: complex
- spec:
- description: Specific attributes of the object. Will vary based on the I(api_version) and I(kind).
- returned: success
- type: complex
- status:
- description: Current status details for the object.
- returned: success
- type: complex
- items:
- description: Returned only when the I(kind) is a List type resource. Contains a set of objects.
- returned: when resource is a List
- type: list
-'''
-
-from ansible.module_utils.k8s.raw import OpenShiftRawModule
-
-
-def main():
- OpenShiftRawModule().execute_module()
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/clustering/openshift/openshift_scale.py b/lib/ansible/modules/clustering/openshift/openshift_scale.py
deleted file mode 100644
index e8e3dd26d9..0000000000
--- a/lib/ansible/modules/clustering/openshift/openshift_scale.py
+++ /dev/null
@@ -1,127 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# (c) 2018, Chris Houseknecht <@chouseknecht>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-
-__metaclass__ = type
-
-ANSIBLE_METADATA = {'metadata_version': '1.1',
- 'status': ['preview'],
- 'supported_by': 'community'}
-
-DOCUMENTATION = '''
-
-module: openshift_scale
-
-short_description: Set a new size for a Deployment Config, Deployment, Replica Set, Replication Controller, or Job.
-
-version_added: "2.5"
-
-author: "Chris Houseknecht (@chouseknecht)"
-
-description:
- - Similar to the oc scale command. Use to set the number of replicas for a Deployment Config, Deployment,
- ReplicatSet, or Replication Controller, or the parallelism attribute of a Job. Supports check mode.
-
-extends_documentation_fragment:
- - k8s_name_options
- - k8s_auth_options
- - k8s_resource_options
- - k8s_scale_options
-
-requirements:
- - "python >= 2.7"
- - "openshift == 0.4.3"
- - "PyYAML >= 3.11"
-'''
-
-EXAMPLES = '''
-- name: Scale deployment config up, and extend timeout
- openshift_scale:
- api_version: v1
- kind: DeploymentConfig
- name: elastic
- namespace: myproject
- replicas: 3
- wait_timeout: 60
-
-- name: Scale deployment config down when current replicas match
- openshift_scale:
- api_version: v1
- kind: DeploymentConfig
- name: elastic
- namespace: myproject
- current_replicas: 3
- replicas: 2
-
-- name: Increase job parallelism
- openshift_scale:
- api_version: batch/v1
- kind: job
- name: pi-with-timeout
- namespace: testing
- replicas: 2
-
-# Match object using local file or inline definition
-
-- name: Scale deployment based on a file from the local filesystem
- openshift_scale:
- src: /myproject/elastic_deployment.yml
- replicas: 3
- wait: no
-
-- name: Scale deployment based on a template output
- openshift_scale:
- resource_definition: "{{ lookup('template', '/myproject/elastic_deployment.yml') | from_yaml }}"
- replicas: 3
- wait: no
-
-- name: Scale deployment based on a file from the Ansible controller filesystem
- openshift_scale:
- resource_definition: "{{ lookup('file', '/myproject/elastic_deployment.yml') | from_yaml }}"
- replicas: 3
- wait: no
-'''
-
-RETURN = '''
-result:
- description:
- - If a change was made, will return the patched object, otherwise returns the existing object.
- returned: success
- type: complex
- contains:
- api_version:
- description: The versioned schema of this representation of an object.
- returned: success
- type: str
- kind:
- description: Represents the REST resource this object represents.
- returned: success
- type: str
- metadata:
- description: Standard object metadata. Includes name, namespace, annotations, labels, etc.
- returned: success
- type: complex
- spec:
- description: Specific attributes of the object. Will vary based on the I(api_version) and I(kind).
- returned: success
- type: complex
- status:
- description: Current status details for the object.
- returned: success
- type: complex
-'''
-
-from ansible.module_utils.k8s.scale import OpenShiftAnsibleScaleModule
-
-
-def main():
- OpenShiftAnsibleScaleModule().execute_module()
-
-
-if __name__ == '__main__':
- main()