mirror of
https://github.com/ansible-collections/kubernetes.core.git
synced 2026-03-27 05:43:02 +00:00
[bp/1.2] Rename from community.kubernetes to kubernetes.core (#111)
This commit is contained in:
@@ -66,7 +66,7 @@ class ActionModule(ActionBase):
|
||||
|
||||
def load_template(self, template, new_module_args, task_vars):
|
||||
# template is only supported by k8s module.
|
||||
if self._task.action not in ('k8s', 'community.kubernetes.k8s', 'community.okd.k8s'):
|
||||
if self._task.action not in ('k8s', 'kubernetes.core.k8s', 'community.okd.k8s'):
|
||||
raise AnsibleActionFail("'template' is only supported parameter for 'k8s' module.")
|
||||
if isinstance(template, string_types):
|
||||
# treat this as raw_params
|
||||
|
||||
@@ -95,20 +95,20 @@ EXAMPLES = '''
|
||||
# File must be named k8s.yaml or k8s.yml
|
||||
|
||||
# Authenticate with token, and return all pods and services for all namespaces
|
||||
plugin: community.kubernetes.k8s
|
||||
plugin: kubernetes.core.k8s
|
||||
connections:
|
||||
- host: https://192.168.64.4:8443
|
||||
api_key: xxxxxxxxxxxxxxxx
|
||||
validate_certs: false
|
||||
|
||||
# Use default config (~/.kube/config) file and active context, and return objects for a specific namespace
|
||||
plugin: community.kubernetes.k8s
|
||||
plugin: kubernetes.core.k8s
|
||||
connections:
|
||||
- namespaces:
|
||||
- testing
|
||||
|
||||
# Use a custom config file, and a specific context.
|
||||
plugin: community.kubernetes.k8s
|
||||
plugin: kubernetes.core.k8s
|
||||
connections:
|
||||
- kubeconfig: /path/to/config
|
||||
context: 'awx/192-168-64-4:8443/developer'
|
||||
@@ -118,10 +118,10 @@ import json
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import (
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||
K8sAnsibleMixin, HAS_K8S_MODULE_HELPER, k8s_import_exception
|
||||
)
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.exceptions import K8sInventoryException
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.exceptions import K8sInventoryException
|
||||
|
||||
try:
|
||||
from openshift.dynamic.exceptions import DynamicApiError
|
||||
@@ -141,9 +141,9 @@ def format_dynamic_api_exc(exc):
|
||||
|
||||
|
||||
class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable, K8sAnsibleMixin):
|
||||
NAME = 'community.kubernetes.k8s'
|
||||
NAME = 'kubernetes.core.k8s'
|
||||
|
||||
connection_plugin = 'community.kubernetes.kubectl'
|
||||
connection_plugin = 'kubernetes.core.kubectl'
|
||||
transport = 'kubectl'
|
||||
|
||||
def parse(self, inventory, loader, path, cache=True):
|
||||
|
||||
@@ -94,26 +94,26 @@ EXAMPLES = '''
|
||||
# File must be named openshift.yaml or openshift.yml
|
||||
|
||||
# Authenticate with token, and return all pods and services for all namespaces
|
||||
plugin: community.kubernetes.openshift
|
||||
plugin: kubernetes.core.openshift
|
||||
connections:
|
||||
- host: https://192.168.64.4:8443
|
||||
api_key: xxxxxxxxxxxxxxxx
|
||||
verify_ssl: false
|
||||
|
||||
# Use default config (~/.kube/config) file and active context, and return objects for a specific namespace
|
||||
plugin: community.kubernetes.openshift
|
||||
plugin: kubernetes.core.openshift
|
||||
connections:
|
||||
- namespaces:
|
||||
- testing
|
||||
|
||||
# Use a custom config file, and a specific context.
|
||||
plugin: community.kubernetes.openshift
|
||||
plugin: kubernetes.core.openshift
|
||||
connections:
|
||||
- kubeconfig: /path/to/config
|
||||
context: 'awx/192-168-64-4:8443/developer'
|
||||
'''
|
||||
|
||||
from ansible_collections.community.kubernetes.plugins.inventory.k8s import K8sInventoryException, InventoryModule as K8sInventoryModule, format_dynamic_api_exc
|
||||
from ansible_collections.kubernetes.core.plugins.inventory.k8s import K8sInventoryException, InventoryModule as K8sInventoryModule, format_dynamic_api_exc
|
||||
|
||||
try:
|
||||
from openshift.dynamic.exceptions import DynamicApiError
|
||||
@@ -122,7 +122,7 @@ except ImportError:
|
||||
|
||||
|
||||
class InventoryModule(K8sInventoryModule):
|
||||
NAME = 'community.kubernetes.openshift'
|
||||
NAME = 'kubernetes.core.openshift'
|
||||
|
||||
transport = 'oc'
|
||||
|
||||
|
||||
@@ -133,23 +133,23 @@ DOCUMENTATION = '''
|
||||
EXAMPLES = """
|
||||
- name: Fetch a list of namespaces
|
||||
set_fact:
|
||||
projects: "{{ lookup('community.kubernetes.k8s', api_version='v1', kind='Namespace') }}"
|
||||
projects: "{{ lookup('kubernetes.core.k8s', api_version='v1', kind='Namespace') }}"
|
||||
|
||||
- name: Fetch all deployments
|
||||
set_fact:
|
||||
deployments: "{{ lookup('community.kubernetes.k8s', kind='Deployment') }}"
|
||||
deployments: "{{ lookup('kubernetes.core.k8s', kind='Deployment') }}"
|
||||
|
||||
- name: Fetch all deployments in a namespace
|
||||
set_fact:
|
||||
deployments: "{{ lookup('community.kubernetes.k8s', kind='Deployment', namespace='testing') }}"
|
||||
deployments: "{{ lookup('kubernetes.core.k8s', kind='Deployment', namespace='testing') }}"
|
||||
|
||||
- name: Fetch a specific deployment by name
|
||||
set_fact:
|
||||
deployments: "{{ lookup('community.kubernetes.k8s', kind='Deployment', namespace='testing', resource_name='elastic') }}"
|
||||
deployments: "{{ lookup('kubernetes.core.k8s', kind='Deployment', namespace='testing', resource_name='elastic') }}"
|
||||
|
||||
- name: Fetch with label selector
|
||||
set_fact:
|
||||
service: "{{ lookup('community.kubernetes.k8s', kind='Service', label_selector='app=galaxy') }}"
|
||||
service: "{{ lookup('kubernetes.core.k8s', kind='Service', label_selector='app=galaxy') }}"
|
||||
|
||||
# Use parameters from a YAML config
|
||||
|
||||
@@ -159,11 +159,11 @@ EXAMPLES = """
|
||||
|
||||
- name: Using the config (loaded from a file in prior task), fetch the latest version of the object
|
||||
set_fact:
|
||||
service: "{{ lookup('community.kubernetes.k8s', resource_definition=config) }}"
|
||||
service: "{{ lookup('kubernetes.core.k8s', resource_definition=config) }}"
|
||||
|
||||
- name: Use a config from the local filesystem
|
||||
set_fact:
|
||||
service: "{{ lookup('community.kubernetes.k8s', src='service.yml') }}"
|
||||
service: "{{ lookup('kubernetes.core.k8s', src='service.yml') }}"
|
||||
"""
|
||||
|
||||
RETURN = """
|
||||
@@ -198,7 +198,7 @@ from ansible.errors import AnsibleError
|
||||
from ansible.module_utils.common._collections_compat import KeysView
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import K8sAnsibleMixin
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import K8sAnsibleMixin
|
||||
|
||||
|
||||
try:
|
||||
|
||||
@@ -31,7 +31,7 @@ from ansible.module_utils.six import iteritems, string_types
|
||||
from ansible.module_utils._text import to_native, to_bytes, to_text
|
||||
from ansible.module_utils.common.dict_transformations import dict_merge
|
||||
from ansible.module_utils.parsing.convert_bool import boolean
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.exceptions import K8sInventoryException
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.exceptions import K8sInventoryException
|
||||
|
||||
|
||||
K8S_IMP_ERR = None
|
||||
|
||||
@@ -22,7 +22,7 @@ __metaclass__ = type
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import (
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||
K8sAnsibleMixin, AUTH_ARG_SPEC, COMMON_ARG_SPEC, RESOURCE_ARG_SPEC, NAME_ARG_SPEC)
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ __metaclass__ = type
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import (
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||
AUTH_ARG_SPEC, RESOURCE_ARG_SPEC, NAME_ARG_SPEC, K8sAnsibleMixin)
|
||||
|
||||
try:
|
||||
|
||||
@@ -140,12 +140,12 @@ options:
|
||||
default: False
|
||||
version_added: "1.2.0"
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.helm_common_options
|
||||
- kubernetes.core.helm_common_options
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Deploy latest version of Prometheus chart inside monitoring namespace (and create it)
|
||||
community.kubernetes.helm:
|
||||
kubernetes.core.helm:
|
||||
name: test
|
||||
chart_ref: stable/prometheus
|
||||
release_namespace: monitoring
|
||||
@@ -153,12 +153,12 @@ EXAMPLES = r'''
|
||||
|
||||
# From repository
|
||||
- name: Add stable chart repo
|
||||
community.kubernetes.helm_repository:
|
||||
kubernetes.core.helm_repository:
|
||||
name: stable
|
||||
repo_url: "https://kubernetes.github.io/ingress-nginx"
|
||||
|
||||
- name: Deploy latest version of Grafana chart inside monitoring namespace with values
|
||||
community.kubernetes.helm:
|
||||
kubernetes.core.helm:
|
||||
name: test
|
||||
chart_ref: stable/grafana
|
||||
release_namespace: monitoring
|
||||
@@ -166,14 +166,14 @@ EXAMPLES = r'''
|
||||
replicas: 2
|
||||
|
||||
- name: Deploy Grafana chart on 5.0.12 with values loaded from template
|
||||
community.kubernetes.helm:
|
||||
kubernetes.core.helm:
|
||||
name: test
|
||||
chart_ref: stable/grafana
|
||||
chart_version: 5.0.12
|
||||
values: "{{ lookup('template', 'somefile.yaml') | from_yaml }}"
|
||||
|
||||
- name: Deploy Grafana chart using values files on target
|
||||
community.kubernetes.helm:
|
||||
kubernetes.core.helm:
|
||||
name: test
|
||||
chart_ref: stable/grafana
|
||||
release_namespace: monitoring
|
||||
@@ -181,7 +181,7 @@ EXAMPLES = r'''
|
||||
- /path/to/values.yaml
|
||||
|
||||
- name: Remove test release and waiting suppression ending
|
||||
community.kubernetes.helm:
|
||||
kubernetes.core.helm:
|
||||
name: test
|
||||
state: absent
|
||||
wait: true
|
||||
@@ -193,14 +193,14 @@ EXAMPLES = r'''
|
||||
dest: /tmp/helm_repo
|
||||
|
||||
- name: Deploy Grafana chart from local path
|
||||
community.kubernetes.helm:
|
||||
kubernetes.core.helm:
|
||||
name: test
|
||||
chart_ref: /tmp/helm_repo/stable/grafana
|
||||
release_namespace: monitoring
|
||||
|
||||
# From url
|
||||
- name: Deploy Grafana chart on 5.6.0 from url
|
||||
community.kubernetes.helm:
|
||||
kubernetes.core.helm:
|
||||
name: test
|
||||
chart_ref: "https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz"
|
||||
release_namespace: monitoring
|
||||
@@ -272,7 +272,7 @@ except ImportError:
|
||||
IMP_YAML = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib, env_fallback
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm, get_values
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.helm import run_helm, get_values
|
||||
|
||||
|
||||
def get_release(state, release_name):
|
||||
|
||||
@@ -39,12 +39,12 @@ options:
|
||||
type: str
|
||||
aliases: [ namespace ]
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.helm_common_options
|
||||
- kubernetes.core.helm_common_options
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Deploy latest version of Grafana chart inside monitoring namespace
|
||||
community.kubernetes.helm_info:
|
||||
kubernetes.core.helm_info:
|
||||
name: test
|
||||
release_namespace: monitoring
|
||||
'''
|
||||
@@ -99,7 +99,7 @@ except ImportError:
|
||||
IMP_YAML = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib, env_fallback
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm, get_values
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.helm import run_helm, get_values
|
||||
|
||||
|
||||
# Get Release from all deployed releases
|
||||
|
||||
@@ -47,22 +47,22 @@ options:
|
||||
- Required only if C(state=present).
|
||||
type: str
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.helm_common_options
|
||||
- kubernetes.core.helm_common_options
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Install Helm env plugin
|
||||
community.kubernetes.helm_plugin:
|
||||
kubernetes.core.helm_plugin:
|
||||
plugin_path: https://github.com/adamreese/helm-env
|
||||
state: present
|
||||
|
||||
- name: Install Helm plugin from local filesystem
|
||||
community.kubernetes.helm_plugin:
|
||||
kubernetes.core.helm_plugin:
|
||||
plugin_path: https://domain/path/to/plugin.tar.gz
|
||||
state: present
|
||||
|
||||
- name: Remove Helm env plugin
|
||||
community.kubernetes.helm_plugin:
|
||||
kubernetes.core.helm_plugin:
|
||||
plugin_name: env
|
||||
state: absent
|
||||
'''
|
||||
@@ -96,7 +96,7 @@ rc:
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.helm import run_helm
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -32,15 +32,15 @@ options:
|
||||
- Name of Helm plugin, to gather particular plugin info.
|
||||
type: str
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.helm_common_options
|
||||
- kubernetes.core.helm_common_options
|
||||
'''
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Gather Helm plugin info
|
||||
community.kubernetes.helm_plugin_info:
|
||||
kubernetes.core.helm_plugin_info:
|
||||
|
||||
- name: Gather Helm env plugin info
|
||||
community.kubernetes.helm_plugin_info:
|
||||
kubernetes.core.helm_plugin_info:
|
||||
plugin_name: env
|
||||
'''
|
||||
|
||||
@@ -77,7 +77,7 @@ rc:
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.helm import run_helm
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -68,12 +68,12 @@ options:
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Add a repository
|
||||
community.kubernetes.helm_repository:
|
||||
kubernetes.core.helm_repository:
|
||||
name: stable
|
||||
repo_url: https://kubernetes.github.io/ingress-nginx
|
||||
|
||||
- name: Add Red Hat Helm charts repository
|
||||
community.kubernetes.helm_repository:
|
||||
kubernetes.core.helm_repository:
|
||||
name: redhat-charts
|
||||
repo_url: https://redhat-developer.github.com/redhat-helm-charts
|
||||
'''
|
||||
@@ -121,7 +121,7 @@ except ImportError:
|
||||
IMP_YAML = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.helm import run_helm
|
||||
|
||||
|
||||
# Get repository from all repositories added
|
||||
|
||||
@@ -83,12 +83,12 @@ options:
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Render templates to specified directory
|
||||
community.kubernetes.helm_template:
|
||||
kubernetes.core.helm_template:
|
||||
chart_ref: stable/prometheus
|
||||
output_dir: mycharts
|
||||
|
||||
- name: Render templates
|
||||
community.kubernetes.helm_template:
|
||||
kubernetes.core.helm_template:
|
||||
chart_ref: stable/prometheus
|
||||
register: result
|
||||
|
||||
@@ -127,7 +127,7 @@ except ImportError:
|
||||
IMP_YAML = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.helm import run_helm
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.helm import run_helm
|
||||
|
||||
|
||||
def template(cmd, chart_ref, chart_repo_url=None, chart_version=None, output_dir=None,
|
||||
|
||||
@@ -24,17 +24,17 @@ 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(community.kubernetes.k8s_info) module to obtain a list of items about an object of type C(kind)
|
||||
- Use the M(kubernetes.core.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.
|
||||
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.k8s_state_options
|
||||
- community.kubernetes.k8s_name_options
|
||||
- community.kubernetes.k8s_resource_options
|
||||
- community.kubernetes.k8s_auth_options
|
||||
- community.kubernetes.k8s_wait_options
|
||||
- community.kubernetes.k8s_delete_options
|
||||
- kubernetes.core.k8s_state_options
|
||||
- kubernetes.core.k8s_name_options
|
||||
- kubernetes.core.k8s_resource_options
|
||||
- kubernetes.core.k8s_auth_options
|
||||
- kubernetes.core.k8s_wait_options
|
||||
- kubernetes.core.k8s_delete_options
|
||||
|
||||
notes:
|
||||
- If your OpenShift Python library is not 0.9.0 or newer and you are trying to
|
||||
@@ -132,14 +132,14 @@ requirements:
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Create a k8s namespace
|
||||
community.kubernetes.k8s:
|
||||
kubernetes.core.k8s:
|
||||
name: testing
|
||||
api_version: v1
|
||||
kind: Namespace
|
||||
state: present
|
||||
|
||||
- name: Create a Service object from an inline definition
|
||||
community.kubernetes.k8s:
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
definition:
|
||||
apiVersion: v1
|
||||
@@ -161,7 +161,7 @@ EXAMPLES = r'''
|
||||
port: 8000
|
||||
|
||||
- name: Remove an existing Service object
|
||||
community.kubernetes.k8s:
|
||||
kubernetes.core.k8s:
|
||||
state: absent
|
||||
api_version: v1
|
||||
kind: Service
|
||||
@@ -171,24 +171,24 @@ EXAMPLES = r'''
|
||||
# Passing the object definition from a file
|
||||
|
||||
- name: Create a Deployment by reading the definition from a local file
|
||||
community.kubernetes.k8s:
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
src: /testing/deployment.yml
|
||||
|
||||
- name: >-
|
||||
Read definition file from the Ansible controller file system.
|
||||
If the definition file has been encrypted with Ansible Vault it will automatically be decrypted.
|
||||
community.kubernetes.k8s:
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
definition: "{{ lookup('file', '/testing/deployment.yml') | from_yaml }}"
|
||||
|
||||
- name: Read definition template file from the Ansible controller file system
|
||||
community.kubernetes.k8s:
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
template: '/testing/deployment.j2'
|
||||
|
||||
- name: Read definition template file from the Ansible controller file system that uses custom start/end strings
|
||||
community.kubernetes.k8s:
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
template:
|
||||
path: '/testing/deployment.j2'
|
||||
@@ -196,14 +196,14 @@ EXAMPLES = r'''
|
||||
variable_end_string: ']]'
|
||||
|
||||
- name: fail on validation errors
|
||||
community.kubernetes.k8s:
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
definition: "{{ lookup('template', '/testing/deployment.yml') | from_yaml }}"
|
||||
validate:
|
||||
fail_on_error: yes
|
||||
|
||||
- name: warn on validation errors, check for unexpected properties
|
||||
community.kubernetes.k8s:
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
definition: "{{ lookup('template', '/testing/deployment.yml') | from_yaml }}"
|
||||
validate:
|
||||
@@ -218,7 +218,7 @@ EXAMPLES = r'''
|
||||
mode: '0664'
|
||||
|
||||
- name: Apply metrics-server manifest to the cluster.
|
||||
community.kubernetes.k8s:
|
||||
kubernetes.core.k8s:
|
||||
state: present
|
||||
src: ~/metrics-server.yaml
|
||||
'''
|
||||
@@ -264,7 +264,7 @@ result:
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import (
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||
K8sAnsibleMixin, COMMON_ARG_SPEC, NAME_ARG_SPEC, RESOURCE_ARG_SPEC, AUTH_ARG_SPEC,
|
||||
WAIT_ARG_SPEC, DELETE_OPTS_ARG_SPEC)
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ EXAMPLES = r'''
|
||||
- include_vars: k8s_passwords.yml
|
||||
|
||||
- name: Log in (obtain access token)
|
||||
community.kubernetes.k8s_auth:
|
||||
kubernetes.core.k8s_auth:
|
||||
username: admin
|
||||
password: "{{ k8s_admin_password }}"
|
||||
register: k8s_auth_results
|
||||
@@ -96,7 +96,7 @@ EXAMPLES = r'''
|
||||
# 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
|
||||
community.kubernetes.k8s_info:
|
||||
kubernetes.core.k8s_info:
|
||||
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
|
||||
kind: Pod
|
||||
register: pod_list
|
||||
@@ -104,7 +104,7 @@ EXAMPLES = r'''
|
||||
always:
|
||||
- name: If login succeeded, try to log out (revoke access token)
|
||||
when: k8s_auth_results.k8s_auth.api_key is defined
|
||||
community.kubernetes.k8s_auth:
|
||||
kubernetes.core.k8s_auth:
|
||||
state: absent
|
||||
api_key: "{{ k8s_auth_results.k8s_auth.api_key }}"
|
||||
'''
|
||||
|
||||
@@ -30,7 +30,7 @@ options:
|
||||
default: True
|
||||
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.k8s_auth_options
|
||||
- kubernetes.core.k8s_auth_options
|
||||
|
||||
requirements:
|
||||
- "python >= 2.7"
|
||||
@@ -40,11 +40,11 @@ requirements:
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Get Cluster information
|
||||
community.kubernetes.k8s_cluster_info:
|
||||
kubernetes.core.k8s_cluster_info:
|
||||
register: api_status
|
||||
|
||||
- name: Do not invalidate cache before getting information
|
||||
community.kubernetes.k8s_cluster_info:
|
||||
kubernetes.core.k8s_cluster_info:
|
||||
invalidate_cache: False
|
||||
register: api_status
|
||||
'''
|
||||
@@ -163,7 +163,7 @@ import traceback
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.parsing.convert_bool import boolean
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import K8sAnsibleMixin, AUTH_ARG_SPEC
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import K8sAnsibleMixin, AUTH_ARG_SPEC
|
||||
|
||||
try:
|
||||
try:
|
||||
|
||||
@@ -23,7 +23,7 @@ description:
|
||||
- Use the Kubernetes Python client to execute command on K8s pods.
|
||||
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.k8s_auth_options
|
||||
- kubernetes.core.k8s_auth_options
|
||||
|
||||
requirements:
|
||||
- "python >= 2.7"
|
||||
@@ -66,13 +66,13 @@ options:
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Execute a command
|
||||
community.kubernetes.k8s_exec:
|
||||
kubernetes.core.k8s_exec:
|
||||
namespace: myproject
|
||||
pod: zuul-scheduler
|
||||
command: zuul-scheduler full-reconfigure
|
||||
|
||||
- name: Check RC status of command executed
|
||||
community.kubernetes.k8s_exec:
|
||||
kubernetes.core.k8s_exec:
|
||||
namespace: myproject
|
||||
pod: busybox-test
|
||||
command: cmd_with_non_zero_exit_code
|
||||
@@ -120,7 +120,7 @@ except ImportError:
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import (
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||
K8sAnsibleMixin, AUTH_ARG_SPEC
|
||||
)
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@ options:
|
||||
elements: str
|
||||
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.k8s_auth_options
|
||||
- community.kubernetes.k8s_name_options
|
||||
- community.kubernetes.k8s_wait_options
|
||||
- kubernetes.core.k8s_auth_options
|
||||
- kubernetes.core.k8s_name_options
|
||||
- kubernetes.core.k8s_wait_options
|
||||
|
||||
requirements:
|
||||
- "python >= 2.7"
|
||||
@@ -56,7 +56,7 @@ requirements:
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Get an existing Service object
|
||||
community.kubernetes.k8s_info:
|
||||
kubernetes.core.k8s_info:
|
||||
api_version: v1
|
||||
kind: Service
|
||||
name: web
|
||||
@@ -64,26 +64,26 @@ EXAMPLES = r'''
|
||||
register: web_service
|
||||
|
||||
- name: Get a list of all service objects
|
||||
community.kubernetes.k8s_info:
|
||||
kubernetes.core.k8s_info:
|
||||
api_version: v1
|
||||
kind: Service
|
||||
namespace: testing
|
||||
register: service_list
|
||||
|
||||
- name: Get a list of all pods from any namespace
|
||||
community.kubernetes.k8s_info:
|
||||
kubernetes.core.k8s_info:
|
||||
kind: Pod
|
||||
register: pod_list
|
||||
|
||||
- name: Search for all Pods labelled app=web
|
||||
community.kubernetes.k8s_info:
|
||||
kubernetes.core.k8s_info:
|
||||
kind: Pod
|
||||
label_selectors:
|
||||
- app = web
|
||||
- tier in (dev, test)
|
||||
|
||||
- name: Using vars while using label_selectors
|
||||
community.kubernetes.k8s_info:
|
||||
kubernetes.core.k8s_info:
|
||||
kind: Pod
|
||||
label_selectors:
|
||||
- "app = {{ app_label_web }}"
|
||||
@@ -91,18 +91,18 @@ EXAMPLES = r'''
|
||||
app_label_web: web
|
||||
|
||||
- name: Search for all running pods
|
||||
community.kubernetes.k8s_info:
|
||||
kubernetes.core.k8s_info:
|
||||
kind: Pod
|
||||
field_selectors:
|
||||
- status.phase=Running
|
||||
|
||||
- name: List custom objects created using CRD
|
||||
community.kubernetes.k8s_info:
|
||||
kubernetes.core.k8s_info:
|
||||
kind: MyCustomObject
|
||||
api_version: "stable.example.com/v1"
|
||||
|
||||
- name: Wait till the Object is created
|
||||
community.kubernetes.k8s_info:
|
||||
kubernetes.core.k8s_info:
|
||||
kind: Pod
|
||||
wait: yes
|
||||
name: pod-not-yet-created
|
||||
@@ -149,7 +149,7 @@ resources:
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import (
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||
K8sAnsibleMixin, AUTH_ARG_SPEC, WAIT_ARG_SPEC)
|
||||
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ description:
|
||||
- Supports check mode.
|
||||
- Analogous to `kubectl logs` or `oc logs`
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.k8s_auth_options
|
||||
- community.kubernetes.k8s_name_options
|
||||
- kubernetes.core.k8s_auth_options
|
||||
- kubernetes.core.k8s_name_options
|
||||
options:
|
||||
kind:
|
||||
description:
|
||||
@@ -63,14 +63,14 @@ requirements:
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Get a log from a Pod
|
||||
community.kubernetes.k8s_log:
|
||||
kubernetes.core.k8s_log:
|
||||
name: example-1
|
||||
namespace: testing
|
||||
register: log
|
||||
|
||||
# This will get the log from the first Pod found matching the selector
|
||||
- name: Log a Pod matching a label selector
|
||||
community.kubernetes.k8s_log:
|
||||
kubernetes.core.k8s_log:
|
||||
namespace: testing
|
||||
label_selectors:
|
||||
- app=example
|
||||
@@ -78,7 +78,7 @@ EXAMPLES = r'''
|
||||
|
||||
# This will get the log from a single Pod managed by this Deployment
|
||||
- name: Get a log from a Deployment
|
||||
community.kubernetes.k8s_log:
|
||||
kubernetes.core.k8s_log:
|
||||
api_version: apps/v1
|
||||
kind: Deployment
|
||||
namespace: testing
|
||||
@@ -87,7 +87,7 @@ EXAMPLES = r'''
|
||||
|
||||
# This will get the log from a single Pod managed by this DeploymentConfig
|
||||
- name: Get a log from a DeploymentConfig
|
||||
community.kubernetes.k8s_log:
|
||||
kubernetes.core.k8s_log:
|
||||
api_version: apps.openshift.io/v1
|
||||
kind: DeploymentConfig
|
||||
namespace: testing
|
||||
@@ -114,7 +114,7 @@ import copy
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six import PY2
|
||||
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import (
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||
K8sAnsibleMixin, AUTH_ARG_SPEC, NAME_ARG_SPEC)
|
||||
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ options:
|
||||
type: list
|
||||
elements: str
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.k8s_auth_options
|
||||
- community.kubernetes.k8s_name_options
|
||||
- kubernetes.core.k8s_auth_options
|
||||
- kubernetes.core.k8s_name_options
|
||||
requirements:
|
||||
- "python >= 2.7"
|
||||
- "openshift >= 0.6"
|
||||
@@ -38,7 +38,7 @@ requirements:
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Rollback a failed deployment
|
||||
community.kubernetes.k8s_rollback:
|
||||
kubernetes.core.k8s_rollback:
|
||||
api_version: apps/v1
|
||||
kind: Deployment
|
||||
name: web
|
||||
@@ -79,7 +79,7 @@ rollback_info:
|
||||
import copy
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import (
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||
K8sAnsibleMixin, AUTH_ARG_SPEC, NAME_ARG_SPEC)
|
||||
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@ description:
|
||||
or Replication Controller, or the parallelism attribute of a Job. Supports check mode.
|
||||
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.k8s_name_options
|
||||
- community.kubernetes.k8s_auth_options
|
||||
- community.kubernetes.k8s_resource_options
|
||||
- community.kubernetes.k8s_scale_options
|
||||
- kubernetes.core.k8s_name_options
|
||||
- kubernetes.core.k8s_auth_options
|
||||
- kubernetes.core.k8s_resource_options
|
||||
- kubernetes.core.k8s_scale_options
|
||||
|
||||
requirements:
|
||||
- "python >= 2.7"
|
||||
@@ -38,7 +38,7 @@ requirements:
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Scale deployment up, and extend timeout
|
||||
community.kubernetes.k8s_scale:
|
||||
kubernetes.core.k8s_scale:
|
||||
api_version: v1
|
||||
kind: Deployment
|
||||
name: elastic
|
||||
@@ -47,7 +47,7 @@ EXAMPLES = r'''
|
||||
wait_timeout: 60
|
||||
|
||||
- name: Scale deployment down when current replicas match
|
||||
community.kubernetes.k8s_scale:
|
||||
kubernetes.core.k8s_scale:
|
||||
api_version: v1
|
||||
kind: Deployment
|
||||
name: elastic
|
||||
@@ -56,7 +56,7 @@ EXAMPLES = r'''
|
||||
replicas: 2
|
||||
|
||||
- name: Increase job parallelism
|
||||
community.kubernetes.k8s_scale:
|
||||
kubernetes.core.k8s_scale:
|
||||
api_version: batch/v1
|
||||
kind: job
|
||||
name: pi-with-timeout
|
||||
@@ -66,19 +66,19 @@ EXAMPLES = r'''
|
||||
# Match object using local file or inline definition
|
||||
|
||||
- name: Scale deployment based on a file from the local filesystem
|
||||
community.kubernetes.k8s_scale:
|
||||
kubernetes.core.k8s_scale:
|
||||
src: /myproject/elastic_deployment.yml
|
||||
replicas: 3
|
||||
wait: no
|
||||
|
||||
- name: Scale deployment based on a template output
|
||||
community.kubernetes.k8s_scale:
|
||||
kubernetes.core.k8s_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
|
||||
community.kubernetes.k8s_scale:
|
||||
kubernetes.core.k8s_scale:
|
||||
resource_definition: "{{ lookup('file', '/myproject/elastic_deployment.yml') | from_yaml }}"
|
||||
replicas: 3
|
||||
wait: no
|
||||
@@ -118,7 +118,7 @@ result:
|
||||
sample: 48
|
||||
'''
|
||||
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.scale import KubernetesAnsibleScaleModule
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.scale import KubernetesAnsibleScaleModule
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -21,9 +21,9 @@ description:
|
||||
- Use Openshift Python SDK to manage Services on Kubernetes
|
||||
|
||||
extends_documentation_fragment:
|
||||
- community.kubernetes.k8s_auth_options
|
||||
- community.kubernetes.k8s_resource_options
|
||||
- community.kubernetes.k8s_state_options
|
||||
- kubernetes.core.k8s_auth_options
|
||||
- kubernetes.core.k8s_resource_options
|
||||
- kubernetes.core.k8s_state_options
|
||||
|
||||
options:
|
||||
merge_type:
|
||||
@@ -91,7 +91,7 @@ requirements:
|
||||
|
||||
EXAMPLES = r'''
|
||||
- name: Expose https port with ClusterIP
|
||||
community.kubernetes.k8s_service:
|
||||
kubernetes.core.k8s_service:
|
||||
state: present
|
||||
name: test-https
|
||||
namespace: default
|
||||
@@ -102,7 +102,7 @@ EXAMPLES = r'''
|
||||
key: special
|
||||
|
||||
- name: Expose https port with ClusterIP using spec
|
||||
community.kubernetes.k8s_service:
|
||||
kubernetes.core.k8s_service:
|
||||
state: present
|
||||
name: test-https
|
||||
namespace: default
|
||||
@@ -150,7 +150,7 @@ import traceback
|
||||
from collections import defaultdict
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.kubernetes.plugins.module_utils.common import (
|
||||
from ansible_collections.kubernetes.core.plugins.module_utils.common import (
|
||||
K8sAnsibleMixin, AUTH_ARG_SPEC, COMMON_ARG_SPEC, RESOURCE_ARG_SPEC)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user