diff --git a/README.md b/README.md index ea9428a713..8a62d78f0f 100644 --- a/README.md +++ b/README.md @@ -6,33 +6,60 @@ This repo hosts the `kubernetes.core` (formerly known as `community.kubernetes`) The collection includes a variety of Ansible content to help automate the management of applications in Kubernetes and OpenShift clusters, as well as the provisioning and maintenance of clusters themselves. + +## Ansible version compatibility + +This collection has been tested against following Ansible versions: **>=2.9.17**. + +Plugins and modules within a collection may be tested with only specific Ansible versions. +A collection may contain metadata that identifies these versions. +PEP440 is the schema used to describe the versions of Ansible. + + ## Included content Click on the name of a plugin or module to view that content's documentation: - - **Connection Plugins**: - - [kubectl](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/kubectl_connection.html) - - **Filter Plugins**: - - [k8s_config_resource_name](https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#kubernetes-filters) - - **Inventory Source**: - - [k8s](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_inventory.html) - - [openshift](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/openshift_inventory.html) - - **Lookup Plugins**: - - [k8s](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_lookup.html) - - **Modules**: - - [k8s](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_module.html) - - [k8s_cluster_info](https://github.com/ansible-collections/kubernetes.core/blob/main/plugins/modules/k8s_cluster_info.py) - - [k8s_exec](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_exec_module.html) - - [k8s_info](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_info_module.html) - - [k8s_log](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_log_module.html) - - [k8s_scale](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_scale_module.html) - - [k8s_service](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/k8s_service_module.html) - - [helm](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/helm_module.html) - - [helm_info](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/helm_info_module.html) - - [helm_plugin](https://github.com/ansible-collections/kubernetes.core/blob/main/plugins/modules/helm_plugin.py) - - [helm_plugin_info](https://github.com/ansible-collections/kubernetes.core/blob/main/plugins/modules/helm_plugin_info.py) - - [helm_repository](https://docs.ansible.com/ansible/2.10/collections/community/kubernetes/helm_repository_module.html) - - [helm_template](https://github.com/ansible-collections/kubernetes.core/blob/main/plugins/modules/helm_template.py) + +### Connection plugins +Name | Description +--- | --- +[kubernetes.core.kubectl](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.kubectl_connection.rst)|Execute tasks in pods running on Kubernetes. + +### Filter plugins +Name | Description +--- | --- +kubernetes.core.k8s_config_resource_name|kubernetes.core k8s_config_resource_name filter plugin + +### Lookup plugins +Name | Description +--- | --- +[kubernetes.core.k8s](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.k8s_lookup.rst)|Query the K8s API + +### Modules +Name | Description +--- | --- +[kubernetes.core.helm](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.helm_module.rst)|Manages Kubernetes packages with the Helm package manager +[kubernetes.core.helm_info](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.helm_info_module.rst)|Get information from Helm package deployed inside the cluster +[kubernetes.core.helm_plugin](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.helm_plugin_module.rst)|Manage Helm plugins +[kubernetes.core.helm_plugin_info](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.helm_plugin_info_module.rst)|Gather information about Helm plugins +[kubernetes.core.helm_repository](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.helm_repository_module.rst)|Manage Helm repositories. +[kubernetes.core.helm_template](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.helm_template_module.rst)|Render chart templates +[kubernetes.core.k8s](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.k8s_module.rst)|Manage Kubernetes (K8s) objects +[kubernetes.core.k8s_cluster_info](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.k8s_cluster_info_module.rst)|Describe Kubernetes (K8s) cluster, APIs available and their respective versions +[kubernetes.core.k8s_exec](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.k8s_exec_module.rst)|Execute command in Pod +[kubernetes.core.k8s_info](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.k8s_info_module.rst)|Describe Kubernetes (K8s) objects +[kubernetes.core.k8s_log](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.k8s_log_module.rst)|Fetch logs from Kubernetes resources +[kubernetes.core.k8s_rollback](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.k8s_rollback_module.rst)|Rollback Kubernetes (K8S) Deployments and DaemonSets +[kubernetes.core.k8s_scale](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.k8s_scale_module.rst)|Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job. +[kubernetes.core.k8s_service](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.k8s_service_module.rst)|Manage Services on Kubernetes + +### Inventory plugins +Name | Description +--- | --- +[kubernetes.core.k8s](https://github.com/ansible-collections/community.kubernetes/blob/main/docs/kubernetes.core.k8s_inventory.rst)|Kubernetes (K8s) inventory source + + ## Installation and Usage diff --git a/changelogs/fragments/add_docs.yml b/changelogs/fragments/add_docs.yml new file mode 100644 index 0000000000..e661318ee9 --- /dev/null +++ b/changelogs/fragments/add_docs.yml @@ -0,0 +1,3 @@ +--- +minor_changes: +- added documentation for ``kubernetes.core`` collection. diff --git a/docs/kubernetes.core.helm_info_module.rst b/docs/kubernetes.core.helm_info_module.rst new file mode 100644 index 0000000000..8d28a33105 --- /dev/null +++ b/docs/kubernetes.core.helm_info_module.rst @@ -0,0 +1,381 @@ +.. _kubernetes.core.helm_info_module: + + +************************* +kubernetes.core.helm_info +************************* + +**Get information from Helm package deployed inside the cluster** + + +Version added: 0.11.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Get information (values, states, ...) from Helm package deployed inside the cluster. + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- helm (https://github.com/helm/helm/releases) +- yaml (https://pypi.org/project/PyYAML/) + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ api_key + +
+ string +
+
added in 1.2.0
+
+ +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ binary_path + +
+ path +
+
+ +
The path of a helm binary to use.
+
+
+ ca_cert + +
+ path +
+
added in 1.2.0
+
+ +
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ context + +
+ string +
+
+ +
Helm option to specify which kubeconfig context to use.
+
If the value is not specified in the task, the value of environment variable K8S_AUTH_CONTEXT will be used instead.
+

aliases: kube_context
+
+
+ host + +
+ string +
+
added in 1.2.0
+
+ +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kubeconfig + +
+ path +
+
+ +
Helm option to specify kubeconfig path to use.
+
If the value is not specified in the task, the value of environment variable K8S_AUTH_KUBECONFIG will be used instead.
+

aliases: kubeconfig_path
+
+
+ release_name + +
+ string + / required +
+
+ +
Release name to manage.
+

aliases: name
+
+
+ release_namespace + +
+ string + / required +
+
+ +
Kubernetes namespace where the chart should be installed.
+

aliases: namespace
+
+
+ validate_certs + +
+ boolean +
+
added in 1.2.0
+
+
    Choices: +
  • no
  • +
  • yes ←
  • +
+
+
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Deploy latest version of Grafana chart inside monitoring namespace + community.kubernetes.helm_info: + name: test + release_namespace: monitoring + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ status + +
+ complex +
+
only when release exists +
A dictionary of status output
+
+
  +
+ appversion + +
+ string +
+
always +
Version of app deployed
+
+
  +
+ chart + +
+ string +
+
always +
Chart name and chart version
+
+
  +
+ name + +
+ string +
+
always +
Name of the release
+
+
  +
+ namespace + +
+ string +
+
always +
Namespace where the release is deployed
+
+
  +
+ revision + +
+ string +
+
always +
Number of time where the release has been updated
+
+
  +
+ status + +
+ string +
+
always +
Status of release (can be DEPLOYED, FAILED, ...)
+
+
  +
+ updated + +
+ string +
+
always +
The Date of last update
+
+
  +
+ values + +
+ string +
+
always +
Dict of Values used to deploy
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Lucas Boisserie (@LucasBoisserie) diff --git a/docs/kubernetes.core.helm_module.rst b/docs/kubernetes.core.helm_module.rst new file mode 100644 index 0000000000..7744d83f05 --- /dev/null +++ b/docs/kubernetes.core.helm_module.rst @@ -0,0 +1,782 @@ +.. _kubernetes.core.helm_module: + + +******************** +kubernetes.core.helm +******************** + +**Manages Kubernetes packages with the Helm package manager** + + +Version added: 0.11.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Install, upgrade, delete packages with the Helm package manager. + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- helm (https://github.com/helm/helm/releases) +- yaml (https://pypi.org/project/PyYAML/) + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ api_key + +
+ string +
+
added in 1.2.0
+
+ +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ atomic + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
If set, the installation process deletes the installation on failure.
+
+
+ binary_path + +
+ path +
+
+ +
The path of a helm binary to use.
+
+
+ ca_cert + +
+ path +
+
added in 1.2.0
+
+ +
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ chart_ref + +
+ path +
+
+ +
chart_reference on chart repository.
+
path to a packaged chart.
+
path to an unpacked chart directory.
+
absolute URL.
+
Required when release_state is set to present.
+
+
+ chart_repo_url + +
+ string +
+
+ +
Chart repository URL where to locate the requested chart.
+
+
+ chart_version + +
+ string +
+
+ +
Chart version to install. If this is not specified, the latest version is installed.
+
+
+ context + +
+ string +
+
+ +
Helm option to specify which kubeconfig context to use.
+
If the value is not specified in the task, the value of environment variable K8S_AUTH_CONTEXT will be used instead.
+

aliases: kube_context
+
+
+ create_namespace + +
+ boolean +
+
added in 0.11.1
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Create the release namespace if not present.
+
+
+ disable_hook + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Helm option to disable hook on install/upgrade/delete.
+
+
+ force + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Helm option to force reinstall, ignore on new install.
+
+
+ host + +
+ string +
+
added in 1.2.0
+
+ +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kubeconfig + +
+ path +
+
+ +
Helm option to specify kubeconfig path to use.
+
If the value is not specified in the task, the value of environment variable K8S_AUTH_KUBECONFIG will be used instead.
+

aliases: kubeconfig_path
+
+
+ purge + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes ←
  • +
+
+
Remove the release from the store and make its name free for later use.
+
+
+ release_name + +
+ string + / required +
+
+ +
Release name to manage.
+

aliases: name
+
+
+ release_namespace + +
+ string + / required +
+
+ +
Kubernetes namespace where the chart should be installed.
+

aliases: namespace
+
+
+ release_state + +
+ string +
+
+
    Choices: +
  • present ←
  • +
  • absent
  • +
+
+
Desirated state of release.
+

aliases: state
+
+
+ release_values + +
+ dictionary +
+
+ Default:
{}
+
+
Value to pass to chart.
+

aliases: values
+
+
+ replace + +
+ boolean +
+
added in 1.11.0
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Reuse the given name, only if that name is a deleted release which remains in the history.
+
This is unsafe in production environment.
+
+
+ skip_crds + +
+ boolean +
+
added in 1.2.0
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Skip custom resource definitions when installing or upgrading.
+
+
+ update_repo_cache + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Run helm repo update before the operation. Can be run as part of the package installation or as a separate step.
+
+
+ validate_certs + +
+ boolean +
+
added in 1.2.0
+
+
    Choices: +
  • no
  • +
  • yes ←
  • +
+
+
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ values_files + +
+ list + / elements=string +
+
added in 1.1.0
+
+ Default:
[]
+
+
Value files to pass to chart.
+
Paths will be read from the target host's filesystem, not the host running ansible.
+
values_files option is evaluated before values option if both are used.
+
Paths are evaluated in the order the paths are specified.
+
+
+ wait + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful.
+
+
+ wait_timeout + +
+ string +
+
+ +
Timeout when wait option is enabled (helm2 is a number of seconds, helm3 is a duration).
+
+
+ + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Deploy latest version of Prometheus chart inside monitoring namespace (and create it) + community.kubernetes.helm: + name: test + chart_ref: stable/prometheus + release_namespace: monitoring + create_namespace: true + + # From repository + - name: Add stable chart repo + community.kubernetes.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: + name: test + chart_ref: stable/grafana + release_namespace: monitoring + values: + replicas: 2 + + - name: Deploy Grafana chart on 5.0.12 with values loaded from template + community.kubernetes.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: + name: test + chart_ref: stable/grafana + release_namespace: monitoring + values_files: + - /path/to/values.yaml + + - name: Remove test release and waiting suppression ending + community.kubernetes.helm: + name: test + state: absent + wait: true + + # From git + - name: Git clone stable repo on HEAD + ansible.builtin.git: + repo: "http://github.com/helm/charts.git" + dest: /tmp/helm_repo + + - name: Deploy Grafana chart from local path + community.kubernetes.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: + name: test + chart_ref: "https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz" + release_namespace: monitoring + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ command + +
+ string +
+
always +
Full `helm` command built by this module, in case you want to re-run the command outside the module or debug a problem.
+
+
Sample:
+
helm upgrade ...
+
+
+ status + +
+ complex +
+
on success Creation/Upgrade/Already deploy +
A dictionary of status output
+
+
  +
+ appversion + +
+ string +
+
always +
Version of app deployed
+
+
  +
+ chart + +
+ string +
+
always +
Chart name and chart version
+
+
  +
+ name + +
+ string +
+
always +
Name of the release
+
+
  +
+ namespace + +
+ string +
+
always +
Namespace where the release is deployed
+
+
  +
+ revision + +
+ string +
+
always +
Number of time where the release has been updated
+
+
  +
+ status + +
+ string +
+
always +
Status of release (can be DEPLOYED, FAILED, ...)
+
+
  +
+ updated + +
+ string +
+
always +
The Date of last update
+
+
  +
+ values + +
+ string +
+
always +
Dict of Values used to deploy
+
+
+
+ stderr + +
+ string +
+
always +
Full `helm` command stderr, in case you want to display it or examine the event log
+
+
+
+ stdout + +
+ string +
+
always +
Full `helm` command stdout, in case you want to display it or examine the event log
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Lucas Boisserie (@LucasBoisserie) +- Matthieu Diehr (@d-matt) diff --git a/docs/kubernetes.core.helm_plugin_info_module.rst b/docs/kubernetes.core.helm_plugin_info_module.rst new file mode 100644 index 0000000000..72bdc5847c --- /dev/null +++ b/docs/kubernetes.core.helm_plugin_info_module.rst @@ -0,0 +1,316 @@ +.. _kubernetes.core.helm_plugin_info_module: + + +******************************** +kubernetes.core.helm_plugin_info +******************************** + +**Gather information about Helm plugins** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Gather information about Helm plugins installed in namespace. + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- helm (https://github.com/helm/helm/releases) + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ api_key + +
+ string +
+
added in 1.2.0
+
+ +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ binary_path + +
+ path +
+
+ +
The path of a helm binary to use.
+
+
+ ca_cert + +
+ path +
+
added in 1.2.0
+
+ +
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ context + +
+ string +
+
+ +
Helm option to specify which kubeconfig context to use.
+
If the value is not specified in the task, the value of environment variable K8S_AUTH_CONTEXT will be used instead.
+

aliases: kube_context
+
+
+ host + +
+ string +
+
added in 1.2.0
+
+ +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kubeconfig + +
+ path +
+
+ +
Helm option to specify kubeconfig path to use.
+
If the value is not specified in the task, the value of environment variable K8S_AUTH_KUBECONFIG will be used instead.
+

aliases: kubeconfig_path
+
+
+ plugin_name + +
+ string +
+
+ +
Name of Helm plugin, to gather particular plugin info.
+
+
+ release_namespace + +
+ string +
+
+ +
Kubernetes namespace where the helm plugins are installed.
+

aliases: namespace
+
+
+ validate_certs + +
+ boolean +
+
added in 1.2.0
+
+
    Choices: +
  • no
  • +
  • yes ←
  • +
+
+
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Gather Helm plugin info + community.kubernetes.helm_plugin_info: + + - name: Gather Helm env plugin info + community.kubernetes.helm_plugin_info: + plugin_name: env + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ command + +
+ string +
+
always +
Full `helm` command built by this module, in case you want to re-run the command outside the module or debug a problem.
+
+
Sample:
+
helm plugin list ...
+
+
+ plugin_list + +
+ list +
+
always +
Helm plugin dict inside a list
+
+
Sample:
+
{'name': 'env', 'version': '0.1.0', 'description': 'Print out the helm environment.'}
+
+
+ rc + +
+ integer +
+
always +
Helm plugin command return code
+
+
Sample:
+
1
+
+
+ stderr + +
+ string +
+
always +
Full `helm` command stderr, in case you want to display it or examine the event log
+
+
+
+ stdout + +
+ string +
+
always +
Full `helm` command stdout, in case you want to display it or examine the event log
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Abhijeet Kasurde (@Akasurde) diff --git a/docs/kubernetes.core.helm_plugin_module.rst b/docs/kubernetes.core.helm_plugin_module.rst new file mode 100644 index 0000000000..75d6c8365b --- /dev/null +++ b/docs/kubernetes.core.helm_plugin_module.rst @@ -0,0 +1,362 @@ +.. _kubernetes.core.helm_plugin_module: + + +*************************** +kubernetes.core.helm_plugin +*************************** + +**Manage Helm plugins** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Manages Helm plugins. + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- helm (https://github.com/helm/helm/releases) + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ api_key + +
+ string +
+
added in 1.2.0
+
+ +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ binary_path + +
+ path +
+
+ +
The path of a helm binary to use.
+
+
+ ca_cert + +
+ path +
+
added in 1.2.0
+
+ +
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ context + +
+ string +
+
+ +
Helm option to specify which kubeconfig context to use.
+
If the value is not specified in the task, the value of environment variable K8S_AUTH_CONTEXT will be used instead.
+

aliases: kube_context
+
+
+ host + +
+ string +
+
added in 1.2.0
+
+ +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kubeconfig + +
+ path +
+
+ +
Helm option to specify kubeconfig path to use.
+
If the value is not specified in the task, the value of environment variable K8S_AUTH_KUBECONFIG will be used instead.
+

aliases: kubeconfig_path
+
+
+ plugin_name + +
+ string +
+
+ +
Name of Helm plugin.
+
Required only if state=absent.
+
+
+ plugin_path + +
+ string +
+
+ +
Plugin path to a plugin on your local file system or a url of a remote VCS repo.
+
If plugin path from file system is provided, make sure that tar is present on remote machine and not on Ansible controller.
+
Required only if state=present.
+
+
+ release_namespace + +
+ string +
+
+ +
Kubernetes namespace where the helm plugin should be installed.
+

aliases: namespace
+
+
+ state + +
+ string +
+
+
    Choices: +
  • absent
  • +
  • present ←
  • +
+
+
If state=present the Helm plugin will be installed.
+
If state=absent the Helm plugin will be removed.
+
+
+ validate_certs + +
+ boolean +
+
added in 1.2.0
+
+
    Choices: +
  • no
  • +
  • yes ←
  • +
+
+
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Install Helm env plugin + community.kubernetes.helm_plugin: + plugin_path: https://github.com/adamreese/helm-env + state: present + + - name: Install Helm plugin from local filesystem + community.kubernetes.helm_plugin: + plugin_path: https://domain/path/to/plugin.tar.gz + state: present + + - name: Remove Helm env plugin + community.kubernetes.helm_plugin: + plugin_name: env + state: absent + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ command + +
+ string +
+
always +
Full `helm` command built by this module, in case you want to re-run the command outside the module or debug a problem.
+
+
Sample:
+
helm plugin list ...
+
+
+ msg + +
+ string +
+
always +
Info about successful command
+
+
Sample:
+
Plugin installed successfully
+
+
+ rc + +
+ integer +
+
always +
Helm plugin command return code
+
+
Sample:
+
1
+
+
+ stderr + +
+ string +
+
always +
Full `helm` command stderr, in case you want to display it or examine the event log
+
+
+
+ stdout + +
+ string +
+
always +
Full `helm` command stdout, in case you want to display it or examine the event log
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Abhijeet Kasurde (@Akasurde) diff --git a/docs/kubernetes.core.helm_repository_module.rst b/docs/kubernetes.core.helm_repository_module.rst new file mode 100644 index 0000000000..1f2d953a02 --- /dev/null +++ b/docs/kubernetes.core.helm_repository_module.rst @@ -0,0 +1,291 @@ +.. _kubernetes.core.helm_repository_module: + + +******************************* +kubernetes.core.helm_repository +******************************* + +**Manage Helm repositories.** + + +Version added: 0.11.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Manage Helm repositories. + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- helm (https://github.com/helm/helm/releases) +- yaml (https://pypi.org/project/PyYAML/) + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ binary_path + +
+ path +
+
+ +
The path of a helm binary to use.
+
+
+ repo_name + +
+ string + / required +
+
+ +
Chart repository name.
+

aliases: name
+
+
+ repo_password + +
+ string +
+
+ +
Chart repository password for repository with basic auth.
+
Required if chart_repo_username is specified.
+

aliases: password
+
+
+ repo_state + +
+ string +
+
+
    Choices: +
  • present ←
  • +
  • absent
  • +
+
+
Desired state of repository.
+

aliases: state
+
+
+ repo_url + +
+ string +
+
+ +
Chart repository url
+

aliases: url
+
+
+ repo_username + +
+ string +
+
+ +
Chart repository username for repository with basic auth.
+
Required if chart_repo_password is specified.
+

aliases: username
+
+
+ + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Add a repository + community.kubernetes.helm_repository: + name: stable + repo_url: https://kubernetes.github.io/ingress-nginx + + - name: Add Red Hat Helm charts repository + community.kubernetes.helm_repository: + name: redhat-charts + repo_url: https://redhat-developer.github.com/redhat-helm-charts + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ command + +
+ string +
+
always +
Full `helm` command built by this module, in case you want to re-run the command outside the module or debug a problem.
+
+
Sample:
+
/usr/local/bin/helm repo add bitnami https://charts.bitnami.com/bitnami
+
+
+ msg + +
+ string +
+
on failure +
Error message returned by `helm` command
+
+
Sample:
+
Repository already have a repository named bitnami
+
+
+ stderr + +
+ string +
+
always +
Full `helm` command stderr, in case you want to display it or examine the event log
+
+
+
+ stderr_lines + +
+ list +
+
always +
Full `helm` command stderr in list, in case you want to display it or examine the event log
+
+
Sample:
+
['']
+
+
+ stdout + +
+ string +
+
always +
Full `helm` command stdout, in case you want to display it or examine the event log
+
+
Sample:
+
"bitnami" has been added to your repositories
+
+
+ stdout_lines + +
+ list +
+
always +
Full `helm` command stdout in list, in case you want to display it or examine the event log
+
+
Sample:
+
['"bitnami" has been added to your repositories']
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Lucas Boisserie (@LucasBoisserie) diff --git a/docs/kubernetes.core.helm_template_module.rst b/docs/kubernetes.core.helm_template_module.rst new file mode 100644 index 0000000000..6d649c457c --- /dev/null +++ b/docs/kubernetes.core.helm_template_module.rst @@ -0,0 +1,288 @@ +.. _kubernetes.core.helm_template_module: + + +***************************** +kubernetes.core.helm_template +***************************** + +**Render chart templates** + + + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Render chart templates to an output directory or as text of concatenated yaml documents. + + + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ binary_path + +
+ path +
+
+ +
The path of a helm binary to use.
+
+
+ chart_ref + +
+ path + / required +
+
+ +
Chart reference with repo prefix, for example, nginx-stable/nginx-ingress.
+
Path to a packaged chart.
+
Path to an unpacked chart directory.
+
Absolute URL.
+
+
+ chart_repo_url + +
+ string +
+
+ +
Chart repository URL where the requested chart is located.
+
+
+ chart_version + +
+ string +
+
+ +
Chart version to use. If this is not specified, the latest version is installed.
+
+
+ include_crds + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Include custom resource descriptions in rendered templates.
+
+
+ output_dir + +
+ path +
+
+ +
Output directory where templates will be written.
+
If the directory already exists, it will be overwritten.
+
+
+ release_values + +
+ dictionary +
+
+ Default:
{}
+
+
Values to pass to chart.
+

aliases: values
+
+
+ update_repo_cache + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Run helm repo update before the operation. Can be run as part of the template generation or as a separate step.
+
+
+ values_files + +
+ list + / elements=string +
+
+ Default:
[]
+
+
Value files to pass to chart.
+
Paths will be read from the target host's filesystem, not the host running ansible.
+
values_files option is evaluated before values option if both are used.
+
Paths are evaluated in the order the paths are specified.
+
+
+ + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Render templates to specified directory + community.kubernetes.helm_template: + chart_ref: stable/prometheus + output_dir: mycharts + + - name: Render templates + community.kubernetes.helm_template: + chart_ref: stable/prometheus + register: result + + - name: Write templates to file + copy: + dest: myfile.yaml + content: "{{ result.stdout }}" + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ command + +
+ string +
+
always +
Full helm command run by this module, in case you want to re-run the command outside the module or debug a problem.
+
+
Sample:
+
helm template --output-dir mychart nginx-stable/nginx-ingress
+
+
+ stderr + +
+ string +
+
always +
Full helm command stderr, in case you want to display it or examine the event log.
+
+
+
+ stdout + +
+ string +
+
always +
Full helm command stdout. If no output_dir has been provided this will contain the rendered templates as concatenated yaml documents.
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Mike Graves (@gravesm) diff --git a/docs/kubernetes.core.k8s_cluster_info_module.rst b/docs/kubernetes.core.k8s_cluster_info_module.rst new file mode 100644 index 0000000000..b63da57080 --- /dev/null +++ b/docs/kubernetes.core.k8s_cluster_info_module.rst @@ -0,0 +1,684 @@ +.. _kubernetes.core.k8s_cluster_info_module: + + +******************************** +kubernetes.core.k8s_cluster_info +******************************** + +**Describe Kubernetes (K8s) cluster, APIs available and their respective versions** + + +Version added: 0.11.1 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Use the OpenShift Python client to perform read operations on K8s objects. +- Authenticate using either a config file, certificates, password or token. +- Supports check mode. + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- python >= 2.7 +- openshift >= 0.6 +- PyYAML >= 3.11 + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ api_key + +
+ string +
+
+ +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ ca_cert + +
+ path +
+
+ +
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ client_cert + +
+ path +
+
+ +
Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.
+

aliases: cert_file
+
+
+ client_key + +
+ path +
+
+ +
Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.
+

aliases: key_file
+
+
+ context + +
+ string +
+
+ +
The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.
+
+
+ host + +
+ string +
+
+ +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ invalidate_cache + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes ←
  • +
+
+
Invalidate cache before retrieving information about cluster.
+
+
+ kubeconfig + +
+ path +
+
+ +
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the openshift client will attempt to load the default configuration file from ~/.kube/config.json. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
+
+ password + +
+ string +
+
+ +
Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.
+
Please read the description of the username option for a discussion of when this option is applicable.
+
+
+ persist_config + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to save the kube config refresh tokens. Can also be specified via K8S_AUTH_PERSIST_CONFIG environment variable.
+
When the k8s context is using a user credentials with refresh tokens (like oidc or gke/gcloud auth), the token is refreshed by the k8s python client library but not saved by default. So the old refresh token can expire and the next auth might fail. Setting this flag to true will tell the k8s python client to save the new refresh token to the kube config file.
+
Default to false.
+
Please note that the current version of the k8s python client library does not support setting this flag to True yet.
+
The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169
+
+
+ proxy + +
+ string +
+
+ +
The URL of an HTTP proxy to use for the connection. Can also be specified via K8S_AUTH_PROXY environment variable.
+
Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).
+
+
+ username + +
+ string +
+
+ +
Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.
+
Please note that this only works with clusters configured to use HTTP Basic Auth. If your cluster has a different form of authentication (e.g. OAuth2 in OpenShift), this option will not work as expected and you should look into the community.okd.k8s_auth module, as that might do what you need.
+
+
+ validate_certs + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ + +Notes +----- + +.. note:: + - The OpenShift Python client wraps the K8s Python client, providing full access to all of the APIS and models available on both platforms. For API version details and additional information visit https://github.com/openshift/openshift-restclient-python + - To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Get Cluster information + community.kubernetes.k8s_cluster_info: + register: api_status + + - name: Do not invalidate cache before getting information + community.kubernetes.k8s_cluster_info: + invalidate_cache: False + register: api_status + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ apis + +
+ dictionary +
+
success +
The APs that exists in dictionary
+
+
  +
+ api_version + +
+ string +
+
success +
API version
+
+
  +
+ available_api_version + +
+ list +
+
success +
All available versions of the given API
+
+
  +
+ categories + +
+ list +
+
success +
API categories
+
+
  +
+ group_version + +
+ string +
+
success +
Resource Group version
+
+
  +
+ kind + +
+ string +
+
success +
Resource kind
+
+
  +
+ name + +
+ string +
+
success +
Resource short name
+
+
  +
+ namespaced + +
+ boolean +
+
success +
If resource is namespaced
+
+
  +
+ preferred + +
+ boolean +
+
success +
If resource version preferred
+
+
  +
+ preferred_api_version + +
+ string +
+
success +
Preferred version of the given API
+
+
  +
+ short_names + +
+ string +
+
success +
Resource short names
+
+
  +
+ singular_name + +
+ string +
+
success +
Resource singular name
+
+
+
+ connection + +
+ dictionary +
+
success +
Connection information
+
+
  +
+ cert_file + +
+ string +
+
success +
Path to client certificate.
+
+
  +
+ host + +
+ string +
+
success +
Host URL
+
+
  +
+ password + +
+ string +
+
success +
User password
+
+
  +
+ proxy + +
+ string +
+
success +
Proxy details
+
+
  +
+ ssl_ca_cert + +
+ string +
+
success +
Path to CA certificate
+
+
  +
+ username + +
+ string +
+
success +
Username
+
+
  +
+ verify_ssl + +
+ boolean +
+
success +
SSL verification status
+
+
+
+ version + +
+ dictionary +
+
success +
Information about server and client version
+
+
  +
+ client + +
+ string +
+
success +
Client version
+
+
  +
+ server + +
+ dictionary +
+
success +
Server version
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Abhijeet Kasurde (@Akasurde) diff --git a/docs/kubernetes.core.k8s_exec_module.rst b/docs/kubernetes.core.k8s_exec_module.rst new file mode 100644 index 0000000000..d2ce897ddc --- /dev/null +++ b/docs/kubernetes.core.k8s_exec_module.rst @@ -0,0 +1,468 @@ +.. _kubernetes.core.k8s_exec_module: + + +************************ +kubernetes.core.k8s_exec +************************ + +**Execute command in Pod** + + +Version added: 0.10.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Use the Kubernetes Python client to execute command on K8s pods. + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- python >= 2.7 +- openshift == 0.4.3 +- PyYAML >= 3.11 + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ api_key + +
+ string +
+
+ +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ ca_cert + +
+ path +
+
+ +
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ client_cert + +
+ path +
+
+ +
Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.
+

aliases: cert_file
+
+
+ client_key + +
+ path +
+
+ +
Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.
+

aliases: key_file
+
+
+ command + +
+ string + / required +
+
+ +
The command to execute
+
+
+ container + +
+ string +
+
+ +
The name of the container in the pod to connect to.
+
Defaults to only container if there is only one container in the pod.
+
+
+ context + +
+ string +
+
+ +
The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.
+
+
+ host + +
+ string +
+
+ +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kubeconfig + +
+ path +
+
+ +
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the openshift client will attempt to load the default configuration file from ~/.kube/config.json. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
+
+ namespace + +
+ string + / required +
+
+ +
The pod namespace name
+
+
+ password + +
+ string +
+
+ +
Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.
+
Please read the description of the username option for a discussion of when this option is applicable.
+
+
+ persist_config + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to save the kube config refresh tokens. Can also be specified via K8S_AUTH_PERSIST_CONFIG environment variable.
+
When the k8s context is using a user credentials with refresh tokens (like oidc or gke/gcloud auth), the token is refreshed by the k8s python client library but not saved by default. So the old refresh token can expire and the next auth might fail. Setting this flag to true will tell the k8s python client to save the new refresh token to the kube config file.
+
Default to false.
+
Please note that the current version of the k8s python client library does not support setting this flag to True yet.
+
The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169
+
+
+ pod + +
+ string + / required +
+
+ +
The pod name
+
+
+ proxy + +
+ string +
+
+ +
The URL of an HTTP proxy to use for the connection.
+
Can also be specified via K8S_AUTH_PROXY environment variable.
+
Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).
+
+
+ username + +
+ string +
+
+ +
Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.
+
Please note that this only works with clusters configured to use HTTP Basic Auth. If your cluster has a different form of authentication (e.g. OAuth2 in OpenShift), this option will not work as expected and you should look into the community.okd.k8s_auth module, as that might do what you need.
+
+
+ validate_certs + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ + +Notes +----- + +.. note:: + - Return code ``return_code`` for the command executed is added in output in version 1.0.0. + - The authenticated user must have at least read access to the pods resource and write access to the pods/exec resource. + - The OpenShift Python client wraps the K8s Python client, providing full access to all of the APIS and models available on both platforms. For API version details and additional information visit https://github.com/openshift/openshift-restclient-python + - To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Execute a command + community.kubernetes.k8s_exec: + namespace: myproject + pod: zuul-scheduler + command: zuul-scheduler full-reconfigure + + - name: Check RC status of command executed + community.kubernetes.k8s_exec: + namespace: myproject + pod: busybox-test + command: cmd_with_non_zero_exit_code + register: command_status + ignore_errors: True + + - name: Check last command status + debug: + msg: "cmd failed" + when: command_status.return_code != 0 + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ result + +
+ complex +
+
success +
The command object
+
+
  +
+ return_code + +
+ integer +
+
+
The command status code
+
+
  +
+ stderr + +
+ string +
+
+
The command stderr
+
+
  +
+ stderr_lines + +
+ string +
+
+
The command stderr
+
+
  +
+ stdout + +
+ string +
+
+
The command stdout
+
+
  +
+ stdout_lines + +
+ string +
+
+
The command stdout
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Tristan de Cacqueray (@tristanC) diff --git a/docs/kubernetes.core.k8s_info_module.rst b/docs/kubernetes.core.k8s_info_module.rst new file mode 100644 index 0000000000..5b966212d2 --- /dev/null +++ b/docs/kubernetes.core.k8s_info_module.rst @@ -0,0 +1,697 @@ +.. _kubernetes.core.k8s_info_module: + + +************************ +kubernetes.core.k8s_info +************************ + +**Describe Kubernetes (K8s) objects** + + + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Use the OpenShift Python client to perform read operations on K8s objects. +- 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 ``k8s_facts`` before Ansible 2.9. The usage did not change. + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- python >= 2.7 +- openshift >= 0.6 +- PyYAML >= 3.11 + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ api_key + +
+ string +
+
+ +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ api_version + +
+ string +
+
+ Default:
"v1"
+
+
Use to specify the API version.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with kind, name, and namespace to identify a specific object.
+
If resource definition is provided, the apiVersion value from the resource_definition will override this option.
+

aliases: api, version
+
+
+ ca_cert + +
+ path +
+
+ +
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ client_cert + +
+ path +
+
+ +
Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.
+

aliases: cert_file
+
+
+ client_key + +
+ path +
+
+ +
Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.
+

aliases: key_file
+
+
+ context + +
+ string +
+
+ +
The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.
+
+
+ field_selectors + +
+ list + / elements=string +
+
+ +
List of field selectors to use to filter results
+
+
+ host + +
+ string +
+
+ +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kind + +
+ string + / required +
+
+ +
Use to specify an object model.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with api_version, name, and namespace to identify a specific object.
+
If resource definition is provided, the kind value from the resource_definition will override this option.
+
+
+ kubeconfig + +
+ path +
+
+ +
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the openshift client will attempt to load the default configuration file from ~/.kube/config.json. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
+
+ label_selectors + +
+ list + / elements=string +
+
+ +
List of label selectors to use to filter results
+
+
+ name + +
+ string +
+
+ +
Use to specify an object name.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with api_version, kind and namespace to identify a specific object.
+
If resource definition is provided, the metadata.name value from the resource_definition will override this option.
+
+
+ namespace + +
+ string +
+
+ +
Use to specify an object namespace.
+
Useful when creating, deleting, or discovering an object without providing a full resource definition.
+
Use in conjunction with api_version, kind, and name to identify a specific object.
+
If resource definition is provided, the metadata.namespace value from the resource_definition will override this option.
+
+
+ password + +
+ string +
+
+ +
Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.
+
Please read the description of the username option for a discussion of when this option is applicable.
+
+
+ persist_config + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to save the kube config refresh tokens. Can also be specified via K8S_AUTH_PERSIST_CONFIG environment variable.
+
When the k8s context is using a user credentials with refresh tokens (like oidc or gke/gcloud auth), the token is refreshed by the k8s python client library but not saved by default. So the old refresh token can expire and the next auth might fail. Setting this flag to true will tell the k8s python client to save the new refresh token to the kube config file.
+
Default to false.
+
Please note that the current version of the k8s python client library does not support setting this flag to True yet.
+
The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169
+
+
+ proxy + +
+ string +
+
+ +
The URL of an HTTP proxy to use for the connection. Can also be specified via K8S_AUTH_PROXY environment variable.
+
Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).
+
+
+ username + +
+ string +
+
+ +
Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.
+
Please note that this only works with clusters configured to use HTTP Basic Auth. If your cluster has a different form of authentication (e.g. OAuth2 in OpenShift), this option will not work as expected and you should look into the community.okd.k8s_auth module, as that might do what you need.
+
+
+ validate_certs + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ wait + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Whether to wait for certain resource kinds to end up in the desired state.
+
By default the module exits once Kubernetes has received the request.
+
Implemented for state=present for Deployment, DaemonSet and Pod, and for state=absent for all resource kinds.
+
For resource kinds without an implementation, wait returns immediately unless wait_condition is set.
+
+
+ wait_condition + +
+ dictionary +
+
+ +
Specifies a custom condition on the status to wait for.
+
Ignored if wait is not set or is set to False.
+
+
+ reason + +
+ string +
+
+ +
The value of the reason field in your desired condition
+
For example, if a Deployment is paused, The Progressing type will have the DeploymentPaused reason.
+
The possible reasons in a condition are specific to each resource type in Kubernetes.
+
See the API documentation of the status field for a given resource to see possible choices.
+
+
+ status + +
+ string +
+
+
    Choices: +
  • True ←
  • +
  • False
  • +
  • Unknown
  • +
+
+
The value of the status field in your desired condition.
+
For example, if a Deployment is paused, the Progressing type will have the Unknown status.
+
+
+ type + +
+ string +
+
+ +
The type of condition to wait for.
+
For example, the Pod resource will set the Ready condition (among others).
+
Required if you are specifying a wait_condition.
+
If left empty, the wait_condition field will be ignored.
+
The possible types for a condition are specific to each resource type in Kubernetes.
+
See the API documentation of the status field for a given resource to see possible choices.
+
+
+ wait_sleep + +
+ integer +
+
+ Default:
5
+
+
Number of seconds to sleep between checks.
+
+
+ wait_timeout + +
+ integer +
+
+ Default:
120
+
+
How long in seconds to wait for the resource to end up in the desired state.
+
Ignored if wait is not set.
+
+
+ + +Notes +----- + +.. note:: + - The OpenShift Python client wraps the K8s Python client, providing full access to all of the APIS and models available on both platforms. For API version details and additional information visit https://github.com/openshift/openshift-restclient-python + - To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Get an existing Service object + community.kubernetes.k8s_info: + api_version: v1 + kind: Service + name: web + namespace: testing + register: web_service + + - name: Get a list of all service objects + community.kubernetes.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: + kind: Pod + register: pod_list + + - name: Search for all Pods labelled app=web + community.kubernetes.k8s_info: + kind: Pod + label_selectors: + - app = web + - tier in (dev, test) + + - name: Using vars while using label_selectors + community.kubernetes.k8s_info: + kind: Pod + label_selectors: + - "app = {{ app_label_web }}" + vars: + app_label_web: web + + - name: Search for all running pods + community.kubernetes.k8s_info: + kind: Pod + field_selectors: + - status.phase=Running + + - name: List custom objects created using CRD + community.kubernetes.k8s_info: + kind: MyCustomObject + api_version: "stable.example.com/v1" + + - name: Wait till the Object is created + community.kubernetes.k8s_info: + kind: Pod + wait: yes + name: pod-not-yet-created + namespace: default + wait_sleep: 10 + wait_timeout: 360 + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ api_found + +
+ boolean +
+
always +
Whether the specified api_version and kind were successfully mapped to an existing API on the targeted cluster.
+
Version added 1.2.0.
+
+
+
+ resources + +
+ complex +
+
success +
The object(s) that exists
+
+
  +
+ api_version + +
+ string +
+
success +
The versioned schema of this representation of an object.
+
+
  +
+ kind + +
+ string +
+
success +
Represents the REST resource this object represents.
+
+
  +
+ metadata + +
+ dictionary +
+
success +
Standard object metadata. Includes name, namespace, annotations, labels, etc.
+
+
  +
+ spec + +
+ dictionary +
+
success +
Specific attributes of the object. Will vary based on the api_version and kind.
+
+
  +
+ status + +
+ dictionary +
+
success +
Current status details for the object.
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Will Thames (@willthames) diff --git a/docs/kubernetes.core.k8s_inventory.rst b/docs/kubernetes.core.k8s_inventory.rst new file mode 100644 index 0000000000..62633797f3 --- /dev/null +++ b/docs/kubernetes.core.k8s_inventory.rst @@ -0,0 +1,358 @@ +.. _kubernetes.core.k8s_inventory: + + +******************* +kubernetes.core.k8s +******************* + +**Kubernetes (K8s) inventory source** + + + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Fetch containers and services for one or more clusters. +- Groups by cluster name, namespace, namespace_services, namespace_pods, and labels. +- Uses the kubectl connection plugin to access the Kubernetes cluster. +- Uses k8s.(yml|yaml) YAML configuration file to set parameter values. + + + +Requirements +------------ +The below requirements are needed on the local Ansible controller node that executes this inventory. + +- python >= 2.7 +- openshift >= 0.6 +- PyYAML >= 3.11 + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsConfigurationComments
+
+ connections + +
+ - +
+
+ + +
Optional list of cluster connection settings. If no connections are provided, the default ~/.kube/config and active context will be used, and objects will be returned for all namespaces the active user is authorized to access.
+
+
+ api_key + +
+ - +
+
+ + +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ ca_cert + +
+ - +
+
+ + +
Path to a CA certificate used to authenticate with the API. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ client_cert + +
+ - +
+
+ + +
Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.
+

aliases: cert_file
+
+
+ client_key + +
+ - +
+
+ + +
Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.
+

aliases: key_file
+
+
+ context + +
+ - +
+
+ + +
The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.
+
+
+ host + +
+ - +
+
+ + +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kubeconfig + +
+ - +
+
+ + +
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the OpenShift client will attempt to load the default configuration file from ~/.kube/config.json. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
+
+ name + +
+ - +
+
+ + +
Optional name to assign to the cluster. If not provided, a name is constructed from the server and port.
+
+
+ namespaces + +
+ - +
+
+ + +
List of namespaces. If not specified, will fetch all containers for all namespaces user is authorized to access.
+
+
+ password + +
+ - +
+
+ + +
Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.
+
+
+ username + +
+ - +
+
+ + +
Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.
+
+
+ validate_certs + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+ +
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ plugin + +
+ - + / required +
+
+
    Choices: +
  • community.kubernetes.k8s
  • +
  • k8s
  • +
+
+ +
token that ensures this is a source file for the 'k8s' plugin.
+
+
+ + + + +Examples +-------- + +.. code-block:: yaml+jinja + + # 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 + 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 + connections: + - namespaces: + - testing + + # Use a custom config file, and a specific context. + plugin: community.kubernetes.k8s + connections: + - kubeconfig: /path/to/config + context: 'awx/192-168-64-4:8443/developer' + + + + +Status +------ + + +Authors +~~~~~~~ + +- Chris Houseknecht <@chouseknecht> +- Fabian von Feilitzsch <@fabianvf> + + +.. hint:: + Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. diff --git a/docs/kubernetes.core.k8s_log_module.rst b/docs/kubernetes.core.k8s_log_module.rst new file mode 100644 index 0000000000..71a1507e05 --- /dev/null +++ b/docs/kubernetes.core.k8s_log_module.rst @@ -0,0 +1,458 @@ +.. _kubernetes.core.k8s_log_module: + + +*********************** +kubernetes.core.k8s_log +*********************** + +**Fetch logs from Kubernetes resources** + + +Version added: 0.10.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Use the OpenShift Python client to perform read operations on K8s log endpoints. +- Authenticate using either a config file, certificates, password or token. +- Supports check mode. +- Analogous to `kubectl logs` or `oc logs` + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- python >= 2.7 +- openshift >= 0.6 +- PyYAML >= 3.11 + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ api_key + +
+ string +
+
+ +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ api_version + +
+ string +
+
+ Default:
"v1"
+
+
Use to specify the API version.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with kind, name, and namespace to identify a specific object.
+
If resource definition is provided, the apiVersion value from the resource_definition will override this option.
+

aliases: api, version
+
+
+ ca_cert + +
+ path +
+
+ +
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ client_cert + +
+ path +
+
+ +
Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.
+

aliases: cert_file
+
+
+ client_key + +
+ path +
+
+ +
Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.
+

aliases: key_file
+
+
+ container + +
+ string +
+
+ +
Use to specify the container within a pod to grab the log from.
+
If there is only one container, this will default to that container.
+
If there is more than one container, this option is required.
+
+
+ context + +
+ string +
+
+ +
The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.
+
+
+ host + +
+ string +
+
+ +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kind + +
+ string +
+
+ Default:
"Pod"
+
+
Use to specify an object model.
+
Use in conjunction with api_version, name, and namespace to identify a specific object.
+
If using label_selectors, cannot be overridden.
+
+
+ kubeconfig + +
+ path +
+
+ +
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the openshift client will attempt to load the default configuration file from ~/.kube/config.json. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
+
+ label_selectors + +
+ list + / elements=string +
+
+ +
List of label selectors to use to filter results
+
Only one of name or label_selectors may be provided.
+
+
+ name + +
+ string +
+
+ +
Use to specify an object name.
+
Use in conjunction with api_version, kind and namespace to identify a specific object.
+
Only one of name or label_selectors may be provided.
+
+
+ namespace + +
+ string +
+
+ +
Use to specify an object namespace.
+
Useful when creating, deleting, or discovering an object without providing a full resource definition.
+
Use in conjunction with api_version, kind, and name to identify a specific object.
+
If resource definition is provided, the metadata.namespace value from the resource_definition will override this option.
+
+
+ password + +
+ string +
+
+ +
Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.
+
Please read the description of the username option for a discussion of when this option is applicable.
+
+
+ persist_config + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to save the kube config refresh tokens. Can also be specified via K8S_AUTH_PERSIST_CONFIG environment variable.
+
When the k8s context is using a user credentials with refresh tokens (like oidc or gke/gcloud auth), the token is refreshed by the k8s python client library but not saved by default. So the old refresh token can expire and the next auth might fail. Setting this flag to true will tell the k8s python client to save the new refresh token to the kube config file.
+
Default to false.
+
Please note that the current version of the k8s python client library does not support setting this flag to True yet.
+
The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169
+
+
+ proxy + +
+ string +
+
+ +
The URL of an HTTP proxy to use for the connection. Can also be specified via K8S_AUTH_PROXY environment variable.
+
Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).
+
+
+ username + +
+ string +
+
+ +
Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.
+
Please note that this only works with clusters configured to use HTTP Basic Auth. If your cluster has a different form of authentication (e.g. OAuth2 in OpenShift), this option will not work as expected and you should look into the community.okd.k8s_auth module, as that might do what you need.
+
+
+ validate_certs + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ + +Notes +----- + +.. note:: + - The OpenShift Python client wraps the K8s Python client, providing full access to all of the APIS and models available on both platforms. For API version details and additional information visit https://github.com/openshift/openshift-restclient-python + - To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Get a log from a Pod + community.kubernetes.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: + namespace: testing + label_selectors: + - app=example + register: log + + # This will get the log from a single Pod managed by this Deployment + - name: Get a log from a Deployment + community.kubernetes.k8s_log: + api_version: apps/v1 + kind: Deployment + namespace: testing + name: example + register: log + + # This will get the log from a single Pod managed by this DeploymentConfig + - name: Get a log from a DeploymentConfig + community.kubernetes.k8s_log: + api_version: apps.openshift.io/v1 + kind: DeploymentConfig + namespace: testing + name: example + register: log + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ log + +
+ string +
+
success +
The text log of the object
+
+
+
+ log_lines + +
+ list +
+
success +
The log of the object, split on newlines
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Fabian von Feilitzsch (@fabianvf) diff --git a/docs/kubernetes.core.k8s_lookup.rst b/docs/kubernetes.core.k8s_lookup.rst new file mode 100644 index 0000000000..f668c388fa --- /dev/null +++ b/docs/kubernetes.core.k8s_lookup.rst @@ -0,0 +1,557 @@ +.. _kubernetes.core.k8s_lookup: + + +******************* +kubernetes.core.k8s +******************* + +**Query the K8s API** + + + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Uses the OpenShift Python client to fetch a specific object by name, all matching objects within a namespace, or all matching objects for all namespaces, as well as information about the cluster. +- Provides access the full range of K8s APIs. +- Enables authentication via config file, certificates, password or token. + + + +Requirements +------------ +The below requirements are needed on the local Ansible controller node that executes this lookup. + +- python >= 2.7 +- openshift >= 0.6 +- PyYAML >= 3.11 + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsConfigurationComments
+
+ api_key + +
+ - +
+
+ + +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ api_version + +
+ - +
+
+ Default:
"v1"
+
+ +
Use to specify the API version. If resource definition is provided, the apiVersion from the resource_definition will override this option.
+
+
+ ca_cert + +
+ - +
+
+ + +
Path to a CA certificate used to authenticate with the API. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ client_cert + +
+ - +
+
+ + +
Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.
+

aliases: cert_file
+
+
+ client_key + +
+ - +
+
+ + +
Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.
+

aliases: key_file
+
+
+ cluster_info + +
+ - +
+
+ + +
Use to specify the type of cluster information you are attempting to retrieve. Will take priority over all the other options.
+
+
+ context + +
+ - +
+
+ + +
The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.
+
+
+ field_selector + +
+ - +
+
+ + +
Specific fields on which to query. Ignored when resource_name is provided.
+
+
+ host + +
+ - +
+
+ + +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kind + +
+ - + / required +
+
+ + +
Use to specify an object model. If resource definition is provided, the kind from a resource_definition will override this option.
+
+
+ kubeconfig + +
+ - +
+
+ + +
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the openshift client will attempt to load the default configuration file from ~/.kube/config.json. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
+
+ label_selector + +
+ - +
+
+ + +
Additional labels to include in the query. Ignored when resource_name is provided.
+
+
+ namespace + +
+ - +
+
+ + +
Limit the objects returned to a specific namespace. If resource definition is provided, the metadata.namespace value from the resource_definition will override this option.
+
+
+ password + +
+ - +
+
+ + +
Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.
+
+
+ resource_definition + +
+ - +
+
+ + +
Provide a YAML configuration for an object. NOTE: kind, api_version, resource_name, and namespace will be overwritten by corresponding values found in the provided resource_definition.
+
+
+ resource_name + +
+ - +
+
+ + +
Fetch a specific object by name. If resource definition is provided, the metadata.name value from the resource_definition will override this option.
+
+
+ src + +
+ - +
+
+ + +
Provide a path to a file containing a valid YAML definition of an object dated. Mutually exclusive with resource_definition. NOTE: kind, api_version, resource_name, and namespace will be overwritten by corresponding values found in the configuration read in from the src file.
+
Reads from the local file system. To read from the Ansible controller's file system, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to resource_definition. See Examples below.
+
+
+ username + +
+ - +
+
+ + +
Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.
+
+
+ validate_certs + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+ +
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ + +Notes +----- + +.. note:: + - The OpenShift Python client wraps the K8s Python client, providing full access to all of the APIS and models available on both platforms. For API version details and additional information visit https://github.com/openshift/openshift-restclient-python + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Fetch a list of namespaces + set_fact: + projects: "{{ lookup('community.kubernetes.k8s', api_version='v1', kind='Namespace') }}" + + - name: Fetch all deployments + set_fact: + deployments: "{{ lookup('community.kubernetes.k8s', kind='Deployment') }}" + + - name: Fetch all deployments in a namespace + set_fact: + deployments: "{{ lookup('community.kubernetes.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') }}" + + - name: Fetch with label selector + set_fact: + service: "{{ lookup('community.kubernetes.k8s', kind='Service', label_selector='app=galaxy') }}" + + # Use parameters from a YAML config + + - name: Load config from the Ansible controller filesystem + set_fact: + config: "{{ lookup('file', 'service.yml') | from_yaml }}" + + - 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) }}" + + - name: Use a config from the local filesystem + set_fact: + service: "{{ lookup('community.kubernetes.k8s', src='service.yml') }}" + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this lookup: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ _list + +
+ complex +
+
+
One ore more object definitions returned from the API.
+
+
  +
+ api_version + +
+ string +
+
success +
The versioned schema of this representation of an object.
+
+
  +
+ kind + +
+ string +
+
success +
Represents the REST resource this object represents.
+
+
  +
+ metadata + +
+ complex +
+
success +
Standard object metadata. Includes name, namespace, annotations, labels, etc.
+
+
  +
+ spec + +
+ complex +
+
success +
Specific attributes of the object. Will vary based on the api_version and kind.
+
+
  +
+ status + +
+ complex +
+
success +
Current status details for the object.
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Chris Houseknecht <@chouseknecht> +- Fabian von Feilitzsch <@fabianvf> + + +.. hint:: + Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. diff --git a/docs/kubernetes.core.k8s_module.rst b/docs/kubernetes.core.k8s_module.rst new file mode 100644 index 0000000000..cdd2b5f3d5 --- /dev/null +++ b/docs/kubernetes.core.k8s_module.rst @@ -0,0 +1,1090 @@ +.. _kubernetes.core.k8s_module: + + +******************* +kubernetes.core.k8s +******************* + +**Manage Kubernetes (K8s) objects** + + + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Use the OpenShift Python client to perform CRUD operations on K8s objects. +- 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 :ref:`community.kubernetes.k8s_info ` module to obtain a list of items about an object of type ``kind`` +- Authenticate using either a config file, certificates, password or token. +- Supports check mode. + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- python >= 2.7 +- openshift >= 0.6 +- PyYAML >= 3.11 + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ api_key + +
+ string +
+
+ +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ api_version + +
+ string +
+
+ Default:
"v1"
+
+
Use to specify the API version.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with kind, name, and namespace to identify a specific object.
+
If resource definition is provided, the apiVersion value from the resource_definition will override this option.
+

aliases: api, version
+
+
+ append_hash + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Whether to append a hash to a resource name for immutability purposes
+
Applies only to ConfigMap and Secret resources
+
The parameter will be silently ignored for other resource kinds
+
The full definition of an object is needed to generate the hash - this means that deleting an object created with append_hash will only work if the same object is passed with state=absent (alternatively, just use state=absent with the name including the generated hash and append_hash=no)
+
Requires openshift >= 0.7.2
+
+
+ apply + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
apply compares the desired resource definition with the previously supplied resource definition, ignoring properties that are automatically generated
+
apply works better with Services than 'force=yes'
+
Requires openshift >= 0.9.2
+
mutually exclusive with merge_type
+
+
+ ca_cert + +
+ path +
+
+ +
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ client_cert + +
+ path +
+
+ +
Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.
+

aliases: cert_file
+
+
+ client_key + +
+ path +
+
+ +
Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.
+

aliases: key_file
+
+
+ context + +
+ string +
+
+ +
The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.
+
+
+ delete_options + +
+ dictionary +
+
added in 1.2.0
+
+ +
Configure behavior when deleting an object.
+
Only used when state=absent.
+
+
+ gracePeriodSeconds + +
+ integer +
+
+ +
Specify how many seconds to wait before forcefully terminating.
+
Only implemented for Pod resources.
+
If not specified, the default grace period for the object type will be used.
+
+
+ preconditions + +
+ dictionary +
+
+ +
Specify condition that must be met for delete to proceed.
+
+
+ resourceVersion + +
+ string +
+
+ +
Specify the resource version of the target object.
+
+
+ uid + +
+ string +
+
+ +
Specify the UID of the target object.
+
+
+ propagationPolicy + +
+ string +
+
+
    Choices: +
  • Foreground
  • +
  • Background
  • +
  • Orphan
  • +
+
+
Use to control how dependent objects are deleted.
+
If not specified, the default policy for the object type will be used. This may vary across object types.
+
+
+ force + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
If set to yes, and state is present, an existing object will be replaced.
+
+
+ host + +
+ string +
+
+ +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kind + +
+ string +
+
+ +
Use to specify an object model.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with api_version, name, and namespace to identify a specific object.
+
If resource definition is provided, the kind value from the resource_definition will override this option.
+
+
+ kubeconfig + +
+ path +
+
+ +
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the openshift client will attempt to load the default configuration file from ~/.kube/config.json. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
+
+ merge_type + +
+ list + / elements=string +
+
+
    Choices: +
  • json
  • +
  • merge
  • +
  • strategic-merge
  • +
+
+
Whether to override the default patch merge approach with a specific type. By default, the strategic merge will typically be used.
+
For example, Custom Resource Definitions typically aren't updatable by the usual strategic merge. You may want to use merge if you see "strategic merge patch format is not supported"
+ +
Requires openshift >= 0.6.2
+
If more than one merge_type is given, the merge_types will be tried in order
+
If openshift >= 0.6.2, this defaults to ['strategic-merge', 'merge'], which is ideal for using the same parameters on resource kinds that combine Custom Resources and built-in resources. For openshift < 0.6.2, the default is simply strategic-merge.
+
mutually exclusive with apply
+
+
+ name + +
+ string +
+
+ +
Use to specify an object name.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with api_version, kind and namespace to identify a specific object.
+
If resource definition is provided, the metadata.name value from the resource_definition will override this option.
+
+
+ namespace + +
+ string +
+
+ +
Use to specify an object namespace.
+
Useful when creating, deleting, or discovering an object without providing a full resource definition.
+
Use in conjunction with api_version, kind, and name to identify a specific object.
+
If resource definition is provided, the metadata.namespace value from the resource_definition will override this option.
+
+
+ password + +
+ string +
+
+ +
Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.
+
Please read the description of the username option for a discussion of when this option is applicable.
+
+
+ persist_config + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to save the kube config refresh tokens. Can also be specified via K8S_AUTH_PERSIST_CONFIG environment variable.
+
When the k8s context is using a user credentials with refresh tokens (like oidc or gke/gcloud auth), the token is refreshed by the k8s python client library but not saved by default. So the old refresh token can expire and the next auth might fail. Setting this flag to true will tell the k8s python client to save the new refresh token to the kube config file.
+
Default to false.
+
Please note that the current version of the k8s python client library does not support setting this flag to True yet.
+
The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169
+
+
+ proxy + +
+ string +
+
+ +
The URL of an HTTP proxy to use for the connection. Can also be specified via K8S_AUTH_PROXY environment variable.
+
Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).
+
+
+ resource_definition + +
+ - +
+
+ +
Provide a valid YAML definition (either as a string, list, or dict) for an object when creating or updating.
+
NOTE: kind, api_version, name, and namespace will be overwritten by corresponding values found in the provided resource_definition.
+

aliases: definition, inline
+
+
+ src + +
+ path +
+
+ +
Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with resource_definition. NOTE: kind, api_version, name, and namespace will be overwritten by corresponding values found in the configuration read in from the src file.
+
Reads from the local file system. To read from the Ansible controller's file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to resource_definition. See Examples below.
+
Mutually exclusive with template in case of k8s module.
+
+
+ state + +
+ string +
+
+
    Choices: +
  • absent
  • +
  • present ←
  • +
+
+
Determines if an object should be created, patched, or deleted. When set to present, an object will be created, if it does not already exist. If set to absent, an existing object will be deleted. If set to present, an existing object will be patched, if its attributes differ from those specified using resource_definition or src.
+
+
+ template + +
+ raw +
+
+ +
Provide a valid YAML template definition file for an object when creating or updating.
+
Value can be provided as string or dictionary.
+
Mutually exclusive with src and resource_definition.
+
Template files needs to be present on the Ansible Controller's file system.
+
Additional parameters can be specified using dictionary.
+
Valid additional parameters -
+
newline_sequence (str): Specify the newline sequence to use for templating files. valid choices are "\n", "\r", "\r\n". Default value "\n".
+
block_start_string (str): The string marking the beginning of a block. Default value "{%".
+
block_end_string (str): The string marking the end of a block. Default value "%}".
+
variable_start_string (str): The string marking the beginning of a print statement. Default value "{{".
+
variable_end_string (str): The string marking the end of a print statement. Default value "}}".
+
trim_blocks (bool): Determine when newlines should be removed from blocks. When set to yes the first newline after a block is removed (block, not variable tag!). Default value is true.
+
lstrip_blocks (bool): Determine when leading spaces and tabs should be stripped. When set to yes leading spaces and tabs are stripped from the start of a line to a block. This functionality requires Jinja 2.7 or newer. Default value is false.
+
+
+ username + +
+ string +
+
+ +
Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.
+
Please note that this only works with clusters configured to use HTTP Basic Auth. If your cluster has a different form of authentication (e.g. OAuth2 in OpenShift), this option will not work as expected and you should look into the community.okd.k8s_auth module, as that might do what you need.
+
+
+ validate + +
+ dictionary +
+
+ +
how (if at all) to validate the resource definition against the kubernetes schema. Requires the kubernetes-validate python module and openshift >= 0.8.0
+
+
+ fail_on_error + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
whether to fail on validation errors.
+
+
+ strict + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes ←
  • +
+
+
whether to fail when passing unexpected properties
+
+
+ version + +
+ string +
+
+ +
version of Kubernetes to validate against. defaults to Kubernetes server version
+
+
+ validate_certs + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ wait + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Whether to wait for certain resource kinds to end up in the desired state.
+
By default the module exits once Kubernetes has received the request.
+
Implemented for state=present for Deployment, DaemonSet and Pod, and for state=absent for all resource kinds.
+
For resource kinds without an implementation, wait returns immediately unless wait_condition is set.
+
+
+ wait_condition + +
+ dictionary +
+
+ +
Specifies a custom condition on the status to wait for.
+
Ignored if wait is not set or is set to False.
+
+
+ reason + +
+ string +
+
+ +
The value of the reason field in your desired condition
+
For example, if a Deployment is paused, The Progressing type will have the DeploymentPaused reason.
+
The possible reasons in a condition are specific to each resource type in Kubernetes.
+
See the API documentation of the status field for a given resource to see possible choices.
+
+
+ status + +
+ string +
+
+
    Choices: +
  • True ←
  • +
  • False
  • +
  • Unknown
  • +
+
+
The value of the status field in your desired condition.
+
For example, if a Deployment is paused, the Progressing type will have the Unknown status.
+
+
+ type + +
+ string +
+
+ +
The type of condition to wait for.
+
For example, the Pod resource will set the Ready condition (among others).
+
Required if you are specifying a wait_condition.
+
If left empty, the wait_condition field will be ignored.
+
The possible types for a condition are specific to each resource type in Kubernetes.
+
See the API documentation of the status field for a given resource to see possible choices.
+
+
+ wait_sleep + +
+ integer +
+
+ Default:
5
+
+
Number of seconds to sleep between checks.
+
+
+ wait_timeout + +
+ integer +
+
+ Default:
120
+
+
How long in seconds to wait for the resource to end up in the desired state.
+
Ignored if wait is not set.
+
+
+ + +Notes +----- + +.. note:: + - If your OpenShift Python library is not 0.9.0 or newer and you are trying to remove an item from an associative array/dictionary, for example a label or an annotation, you will need to explicitly set the value of the item to be removed to `null`. Simply deleting the entry in the dictionary will not remove it from openshift or kubernetes. + - The OpenShift Python client wraps the K8s Python client, providing full access to all of the APIS and models available on both platforms. For API version details and additional information visit https://github.com/openshift/openshift-restclient-python + - To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Create a k8s namespace + community.kubernetes.k8s: + name: testing + api_version: v1 + kind: Namespace + state: present + + - name: Create a Service object from an inline definition + community.kubernetes.k8s: + state: present + definition: + apiVersion: v1 + kind: Service + metadata: + name: web + namespace: testing + labels: + app: galaxy + service: web + spec: + selector: + app: galaxy + service: web + ports: + - protocol: TCP + targetPort: 8000 + name: port-8000-tcp + port: 8000 + + - name: Remove an existing Service object + community.kubernetes.k8s: + state: absent + api_version: v1 + kind: Service + namespace: testing + name: web + + # Passing the object definition from a file + + - name: Create a Deployment by reading the definition from a local file + community.kubernetes.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: + state: present + definition: "{{ lookup('file', '/testing/deployment.yml') | from_yaml }}" + + - name: Read definition template file from the Ansible controller file system + community.kubernetes.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: + state: present + template: + path: '/testing/deployment.j2' + variable_start_string: '[[' + variable_end_string: ']]' + + - name: fail on validation errors + community.kubernetes.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: + state: present + definition: "{{ lookup('template', '/testing/deployment.yml') | from_yaml }}" + validate: + fail_on_error: no + strict: yes + + # Download and apply manifest + - name: Download metrics-server manifest to the cluster. + ansible.builtin.get_url: + url: https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml + dest: ~/metrics-server.yaml + mode: '0664' + + - name: Apply metrics-server manifest to the cluster. + community.kubernetes.k8s: + state: present + src: ~/metrics-server.yaml + + # Wait for a Deployment to pause before continuing + - name: Pause a Deployment. + community.kubernetes.k8s: + definition: + apiVersion: apps/v1 + kind: Deployment + metadata: + name: example + namespace: testing + spec: + paused: True + wait: yes + wait_condition: + type: Progressing + status: Unknown + reason: DeploymentPaused + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ result + +
+ complex +
+
success +
The created, patched, or otherwise present object. Will be empty in the case of a deletion.
+
+
  +
+ api_version + +
+ string +
+
success +
The versioned schema of this representation of an object.
+
+
  +
+ duration + +
+ integer +
+
when wait is true +
elapsed time of task in seconds
+
+
Sample:
+
48
+
  +
+ items + +
+ list +
+
when resource_definition or src contains list of objects +
Returned only when multiple yaml documents are passed to src or resource_definition
+
+
  +
+ kind + +
+ string +
+
success +
Represents the REST resource this object represents.
+
+
  +
+ metadata + +
+ complex +
+
success +
Standard object metadata. Includes name, namespace, annotations, labels, etc.
+
+
  +
+ spec + +
+ complex +
+
success +
Specific attributes of the object. Will vary based on the api_version and kind.
+
+
  +
+ status + +
+ complex +
+
success +
Current status details for the object.
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Chris Houseknecht (@chouseknecht) +- Fabian von Feilitzsch (@fabianvf) diff --git a/docs/kubernetes.core.k8s_rollback_module.rst b/docs/kubernetes.core.k8s_rollback_module.rst new file mode 100644 index 0000000000..31621c7a38 --- /dev/null +++ b/docs/kubernetes.core.k8s_rollback_module.rst @@ -0,0 +1,498 @@ +.. _kubernetes.core.k8s_rollback_module: + + +**************************** +kubernetes.core.k8s_rollback +**************************** + +**Rollback Kubernetes (K8S) Deployments and DaemonSets** + + +Version added: 1.0.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Use the OpenShift Python client to perform the Rollback. +- Authenticate using either a config file, certificates, password or token. +- Similar to the ``kubectl rollout undo`` command. + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- python >= 2.7 +- openshift >= 0.6 +- PyYAML >= 3.11 + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ api_key + +
+ string +
+
+ +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ api_version + +
+ string +
+
+ Default:
"v1"
+
+
Use to specify the API version.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with kind, name, and namespace to identify a specific object.
+
If resource definition is provided, the apiVersion value from the resource_definition will override this option.
+

aliases: api, version
+
+
+ ca_cert + +
+ path +
+
+ +
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ client_cert + +
+ path +
+
+ +
Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.
+

aliases: cert_file
+
+
+ client_key + +
+ path +
+
+ +
Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.
+

aliases: key_file
+
+
+ context + +
+ string +
+
+ +
The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.
+
+
+ field_selectors + +
+ list + / elements=string +
+
+ +
List of field selectors to use to filter results.
+
+
+ host + +
+ string +
+
+ +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kind + +
+ string +
+
+ +
Use to specify an object model.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with api_version, name, and namespace to identify a specific object.
+
If resource definition is provided, the kind value from the resource_definition will override this option.
+
+
+ kubeconfig + +
+ path +
+
+ +
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the openshift client will attempt to load the default configuration file from ~/.kube/config.json. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
+
+ label_selectors + +
+ list + / elements=string +
+
+ +
List of label selectors to use to filter results.
+
+
+ name + +
+ string +
+
+ +
Use to specify an object name.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with api_version, kind and namespace to identify a specific object.
+
If resource definition is provided, the metadata.name value from the resource_definition will override this option.
+
+
+ namespace + +
+ string +
+
+ +
Use to specify an object namespace.
+
Useful when creating, deleting, or discovering an object without providing a full resource definition.
+
Use in conjunction with api_version, kind, and name to identify a specific object.
+
If resource definition is provided, the metadata.namespace value from the resource_definition will override this option.
+
+
+ password + +
+ string +
+
+ +
Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.
+
Please read the description of the username option for a discussion of when this option is applicable.
+
+
+ persist_config + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to save the kube config refresh tokens. Can also be specified via K8S_AUTH_PERSIST_CONFIG environment variable.
+
When the k8s context is using a user credentials with refresh tokens (like oidc or gke/gcloud auth), the token is refreshed by the k8s python client library but not saved by default. So the old refresh token can expire and the next auth might fail. Setting this flag to true will tell the k8s python client to save the new refresh token to the kube config file.
+
Default to false.
+
Please note that the current version of the k8s python client library does not support setting this flag to True yet.
+
The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169
+
+
+ proxy + +
+ string +
+
+ +
The URL of an HTTP proxy to use for the connection. Can also be specified via K8S_AUTH_PROXY environment variable.
+
Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).
+
+
+ username + +
+ string +
+
+ +
Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.
+
Please note that this only works with clusters configured to use HTTP Basic Auth. If your cluster has a different form of authentication (e.g. OAuth2 in OpenShift), this option will not work as expected and you should look into the community.okd.k8s_auth module, as that might do what you need.
+
+
+ validate_certs + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ + +Notes +----- + +.. note:: + - The OpenShift Python client wraps the K8s Python client, providing full access to all of the APIS and models available on both platforms. For API version details and additional information visit https://github.com/openshift/openshift-restclient-python + - To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Rollback a failed deployment + community.kubernetes.k8s_rollback: + api_version: apps/v1 + kind: Deployment + name: web + namespace: testing + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ rollback_info + +
+ complex +
+
success +
The object that was rolled back.
+
+
  +
+ api_version + +
+ string +
+
success +
The versioned schema of this representation of an object.
+
+
  +
+ code + +
+ string +
+
success +
The HTTP Code of the response
+
+
  +
+ kind + +
+ string +
+
success +
Status
+
+
  +
+ metadata + +
+ dictionary +
+
success +
Standard object metadata.
+
Includes name, namespace, annotations, labels, etc.
+
+
  +
+ status + +
+ dictionary +
+
success +
Current status details for the object.
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Julien Huon (@julienhuon) diff --git a/docs/kubernetes.core.k8s_scale_module.rst b/docs/kubernetes.core.k8s_scale_module.rst new file mode 100644 index 0000000000..7604bdfb92 --- /dev/null +++ b/docs/kubernetes.core.k8s_scale_module.rst @@ -0,0 +1,635 @@ +.. _kubernetes.core.k8s_scale_module: + + +************************* +kubernetes.core.k8s_scale +************************* + +**Set a new size for a Deployment, ReplicaSet, Replication Controller, or Job.** + + + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Similar to the kubectl scale command. Use to set the number of replicas for a Deployment, ReplicaSet, or Replication Controller, or the parallelism attribute of a Job. Supports check mode. + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- python >= 2.7 +- openshift >= 0.6 +- PyYAML >= 3.11 + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ api_key + +
+ string +
+
+ +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ api_version + +
+ string +
+
+ Default:
"v1"
+
+
Use to specify the API version.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with kind, name, and namespace to identify a specific object.
+
If resource definition is provided, the apiVersion value from the resource_definition will override this option.
+

aliases: api, version
+
+
+ ca_cert + +
+ path +
+
+ +
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ client_cert + +
+ path +
+
+ +
Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.
+

aliases: cert_file
+
+
+ client_key + +
+ path +
+
+ +
Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.
+

aliases: key_file
+
+
+ context + +
+ string +
+
+ +
The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.
+
+
+ current_replicas + +
+ integer +
+
+ +
For Deployment, ReplicaSet, Replication Controller, only scale, if the number of existing replicas matches. In the case of a Job, update parallelism only if the current parallelism value matches.
+
+
+ host + +
+ string +
+
+ +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kind + +
+ string +
+
+ +
Use to specify an object model.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with api_version, name, and namespace to identify a specific object.
+
If resource definition is provided, the kind value from the resource_definition will override this option.
+
+
+ kubeconfig + +
+ path +
+
+ +
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the openshift client will attempt to load the default configuration file from ~/.kube/config.json. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
+
+ name + +
+ string +
+
+ +
Use to specify an object name.
+
Use to create, delete, or discover an object without providing a full resource definition.
+
Use in conjunction with api_version, kind and namespace to identify a specific object.
+
If resource definition is provided, the metadata.name value from the resource_definition will override this option.
+
+
+ namespace + +
+ string +
+
+ +
Use to specify an object namespace.
+
Useful when creating, deleting, or discovering an object without providing a full resource definition.
+
Use in conjunction with api_version, kind, and name to identify a specific object.
+
If resource definition is provided, the metadata.namespace value from the resource_definition will override this option.
+
+
+ password + +
+ string +
+
+ +
Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.
+
Please read the description of the username option for a discussion of when this option is applicable.
+
+
+ persist_config + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to save the kube config refresh tokens. Can also be specified via K8S_AUTH_PERSIST_CONFIG environment variable.
+
When the k8s context is using a user credentials with refresh tokens (like oidc or gke/gcloud auth), the token is refreshed by the k8s python client library but not saved by default. So the old refresh token can expire and the next auth might fail. Setting this flag to true will tell the k8s python client to save the new refresh token to the kube config file.
+
Default to false.
+
Please note that the current version of the k8s python client library does not support setting this flag to True yet.
+
The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169
+
+
+ proxy + +
+ string +
+
+ +
The URL of an HTTP proxy to use for the connection. Can also be specified via K8S_AUTH_PROXY environment variable.
+
Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).
+
+
+ replicas + +
+ integer + / required +
+
+ +
The desired number of replicas.
+
+
+ resource_definition + +
+ - +
+
+ +
Provide a valid YAML definition (either as a string, list, or dict) for an object when creating or updating.
+
NOTE: kind, api_version, name, and namespace will be overwritten by corresponding values found in the provided resource_definition.
+

aliases: definition, inline
+
+
+ resource_version + +
+ string +
+
+ +
Only attempt to scale, if the current object version matches.
+
+
+ src + +
+ path +
+
+ +
Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with resource_definition. NOTE: kind, api_version, name, and namespace will be overwritten by corresponding values found in the configuration read in from the src file.
+
Reads from the local file system. To read from the Ansible controller's file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to resource_definition. See Examples below.
+
Mutually exclusive with template in case of k8s module.
+
+
+ username + +
+ string +
+
+ +
Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.
+
Please note that this only works with clusters configured to use HTTP Basic Auth. If your cluster has a different form of authentication (e.g. OAuth2 in OpenShift), this option will not work as expected and you should look into the community.okd.k8s_auth module, as that might do what you need.
+
+
+ validate_certs + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ wait + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes ←
  • +
+
+
For Deployment, ReplicaSet, Replication Controller, wait for the status value of ready_replicas to change to the number of replicas. In the case of a Job, this option is ignored.
+
+
+ wait_timeout + +
+ integer +
+
+ Default:
20
+
+
When wait is True, the number of seconds to wait for the ready_replicas status to equal replicas. If the status is not reached within the allotted time, an error will result. In the case of a Job, this option is ignored.
+
+
+ + +Notes +----- + +.. note:: + - The OpenShift Python client wraps the K8s Python client, providing full access to all of the APIS and models available on both platforms. For API version details and additional information visit https://github.com/openshift/openshift-restclient-python + - To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Scale deployment up, and extend timeout + community.kubernetes.k8s_scale: + api_version: v1 + kind: Deployment + name: elastic + namespace: myproject + replicas: 3 + wait_timeout: 60 + + - name: Scale deployment down when current replicas match + community.kubernetes.k8s_scale: + api_version: v1 + kind: Deployment + name: elastic + namespace: myproject + current_replicas: 3 + replicas: 2 + + - name: Increase job parallelism + community.kubernetes.k8s_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 + community.kubernetes.k8s_scale: + src: /myproject/elastic_deployment.yml + replicas: 3 + wait: no + + - name: Scale deployment based on a template output + community.kubernetes.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: + resource_definition: "{{ lookup('file', '/myproject/elastic_deployment.yml') | from_yaml }}" + replicas: 3 + wait: no + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ result + +
+ complex +
+
success +
If a change was made, will return the patched object, otherwise returns the existing object.
+
+
  +
+ api_version + +
+ string +
+
success +
The versioned schema of this representation of an object.
+
+
  +
+ duration + +
+ integer +
+
when wait is true +
elapsed time of task in seconds
+
+
Sample:
+
48
+
  +
+ kind + +
+ string +
+
success +
Represents the REST resource this object represents.
+
+
  +
+ metadata + +
+ complex +
+
success +
Standard object metadata. Includes name, namespace, annotations, labels, etc.
+
+
  +
+ spec + +
+ complex +
+
success +
Specific attributes of the object. Will vary based on the api_version and kind.
+
+
  +
+ status + +
+ complex +
+
success +
Current status details for the object.
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- Chris Houseknecht (@chouseknecht) +- Fabian von Feilitzsch (@fabianvf) diff --git a/docs/kubernetes.core.k8s_service_module.rst b/docs/kubernetes.core.k8s_service_module.rst new file mode 100644 index 0000000000..34b5e4dcc9 --- /dev/null +++ b/docs/kubernetes.core.k8s_service_module.rst @@ -0,0 +1,610 @@ +.. _kubernetes.core.k8s_service_module: + + +*************************** +kubernetes.core.k8s_service +*************************** + +**Manage Services on Kubernetes** + + + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Use Openshift Python SDK to manage Services on Kubernetes + + + +Requirements +------------ +The below requirements are needed on the host that executes this module. + +- python >= 2.7 +- openshift >= 0.6.2 + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ api_key + +
+ string +
+
+ +
Token used to authenticate with the API. Can also be specified via K8S_AUTH_API_KEY environment variable.
+
+
+ apply + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
apply compares the desired resource definition with the previously supplied resource definition, ignoring properties that are automatically generated
+
apply works better with Services than 'force=yes'
+
mutually exclusive with merge_type
+
+
+ ca_cert + +
+ path +
+
+ +
Path to a CA certificate used to authenticate with the API. The full certificate chain must be provided to avoid certificate validation errors. Can also be specified via K8S_AUTH_SSL_CA_CERT environment variable.
+

aliases: ssl_ca_cert
+
+
+ client_cert + +
+ path +
+
+ +
Path to a certificate used to authenticate with the API. Can also be specified via K8S_AUTH_CERT_FILE environment variable.
+

aliases: cert_file
+
+
+ client_key + +
+ path +
+
+ +
Path to a key file used to authenticate with the API. Can also be specified via K8S_AUTH_KEY_FILE environment variable.
+

aliases: key_file
+
+
+ context + +
+ string +
+
+ +
The name of a context found in the config file. Can also be specified via K8S_AUTH_CONTEXT environment variable.
+
+
+ force + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
If set to yes, and state is present, an existing object will be replaced.
+
+
+ host + +
+ string +
+
+ +
Provide a URL for accessing the API. Can also be specified via K8S_AUTH_HOST environment variable.
+
+
+ kubeconfig + +
+ path +
+
+ +
Path to an existing Kubernetes config file. If not provided, and no other connection options are provided, the openshift client will attempt to load the default configuration file from ~/.kube/config.json. Can also be specified via K8S_AUTH_KUBECONFIG environment variable.
+
+
+ merge_type + +
+ list + / elements=string +
+
+
    Choices: +
  • json
  • +
  • merge
  • +
  • strategic-merge
  • +
+
+
Whether to override the default patch merge approach with a specific type. By default, the strategic merge will typically be used.
+
For example, Custom Resource Definitions typically aren't updatable by the usual strategic merge. You may want to use merge if you see "strategic merge patch format is not supported"
+ +
Requires openshift >= 0.6.2
+
If more than one merge_type is given, the merge_types will be tried in order
+
If openshift >= 0.6.2, this defaults to ['strategic-merge', 'merge'], which is ideal for using the same parameters on resource kinds that combine Custom Resources and built-in resources. For openshift < 0.6.2, the default is simply strategic-merge.
+
+
+ name + +
+ string + / required +
+
+ +
Use to specify a Service object name.
+
+
+ namespace + +
+ string + / required +
+
+ +
Use to specify a Service object namespace.
+
+
+ password + +
+ string +
+
+ +
Provide a password for authenticating with the API. Can also be specified via K8S_AUTH_PASSWORD environment variable.
+
Please read the description of the username option for a discussion of when this option is applicable.
+
+
+ persist_config + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to save the kube config refresh tokens. Can also be specified via K8S_AUTH_PERSIST_CONFIG environment variable.
+
When the k8s context is using a user credentials with refresh tokens (like oidc or gke/gcloud auth), the token is refreshed by the k8s python client library but not saved by default. So the old refresh token can expire and the next auth might fail. Setting this flag to true will tell the k8s python client to save the new refresh token to the kube config file.
+
Default to false.
+
Please note that the current version of the k8s python client library does not support setting this flag to True yet.
+
The fix for this k8s python library is here: https://github.com/kubernetes-client/python-base/pull/169
+
+
+ ports + +
+ list + / elements=dictionary +
+
+ +
A list of ports to expose.
+ +
+
+ proxy + +
+ string +
+
+ +
The URL of an HTTP proxy to use for the connection. Can also be specified via K8S_AUTH_PROXY environment variable.
+
Please note that this module does not pick up typical proxy settings from the environment (e.g. HTTP_PROXY).
+
+
+ resource_definition + +
+ - +
+
+ +
Provide a valid YAML definition (either as a string, list, or dict) for an object when creating or updating.
+
NOTE: kind, api_version, name, and namespace will be overwritten by corresponding values found in the provided resource_definition.
+

aliases: definition, inline
+
+
+ selector + +
+ dictionary +
+
+ +
Label selectors identify objects this Service should apply to.
+ +
+
+ src + +
+ path +
+
+ +
Provide a path to a file containing a valid YAML definition of an object or objects to be created or updated. Mutually exclusive with resource_definition. NOTE: kind, api_version, name, and namespace will be overwritten by corresponding values found in the configuration read in from the src file.
+
Reads from the local file system. To read from the Ansible controller's file system, including vaulted files, use the file lookup plugin or template lookup plugin, combined with the from_yaml filter, and pass the result to resource_definition. See Examples below.
+
Mutually exclusive with template in case of k8s module.
+
+
+ state + +
+ string +
+
+
    Choices: +
  • absent
  • +
  • present ←
  • +
+
+
Determines if an object should be created, patched, or deleted. When set to present, an object will be created, if it does not already exist. If set to absent, an existing object will be deleted. If set to present, an existing object will be patched, if its attributes differ from those specified using resource_definition or src.
+
+
+ type + +
+ string +
+
+
    Choices: +
  • NodePort
  • +
  • ClusterIP
  • +
  • LoadBalancer
  • +
  • ExternalName
  • +
+
+
Specifies the type of Service to create.
+ +
+
+ username + +
+ string +
+
+ +
Provide a username for authenticating with the API. Can also be specified via K8S_AUTH_USERNAME environment variable.
+
Please note that this only works with clusters configured to use HTTP Basic Auth. If your cluster has a different form of authentication (e.g. OAuth2 in OpenShift), this option will not work as expected and you should look into the community.okd.k8s_auth module, as that might do what you need.
+
+
+ validate_certs + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+
+
Whether or not to verify the API server's SSL certificates. Can also be specified via K8S_AUTH_VERIFY_SSL environment variable.
+

aliases: verify_ssl
+
+
+ + +Notes +----- + +.. note:: + - The OpenShift Python client wraps the K8s Python client, providing full access to all of the APIS and models available on both platforms. For API version details and additional information visit https://github.com/openshift/openshift-restclient-python + - To avoid SSL certificate validation errors when ``validate_certs`` is *True*, the full certificate chain for the API server must be provided via ``ca_cert`` or in the kubeconfig file. + + + +Examples +-------- + +.. code-block:: yaml+jinja + + - name: Expose https port with ClusterIP + community.kubernetes.k8s_service: + state: present + name: test-https + namespace: default + ports: + - port: 443 + protocol: TCP + selector: + key: special + + - name: Expose https port with ClusterIP using spec + community.kubernetes.k8s_service: + state: present + name: test-https + namespace: default + inline: + spec: + ports: + - port: 443 + protocol: TCP + selector: + key: special + + + +Return Values +------------- +Common return values are documented `here `_, the following are the fields unique to this module: + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyReturnedDescription
+
+ result + +
+ complex +
+
success +
The created, patched, or otherwise present Service object. Will be empty in the case of a deletion.
+
+
  +
+ api_version + +
+ string +
+
success +
The versioned schema of this representation of an object.
+
+
  +
+ kind + +
+ string +
+
success +
Always 'Service'.
+
+
  +
+ metadata + +
+ complex +
+
success +
Standard object metadata. Includes name, namespace, annotations, labels, etc.
+
+
  +
+ spec + +
+ complex +
+
success +
Specific attributes of the object. Will vary based on the api_version and kind.
+
+
  +
+ status + +
+ complex +
+
success +
Current status details for the object.
+
+
+

+ + +Status +------ + + +Authors +~~~~~~~ + +- KubeVirt Team (@kubevirt) diff --git a/docs/kubernetes.core.kubectl_connection.rst b/docs/kubernetes.core.kubectl_connection.rst new file mode 100644 index 0000000000..595ee40596 --- /dev/null +++ b/docs/kubernetes.core.kubectl_connection.rst @@ -0,0 +1,361 @@ +.. _kubernetes.core.kubectl_connection: + + +*********************** +kubernetes.core.kubectl +*********************** + +**Execute tasks in pods running on Kubernetes.** + + + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Use the kubectl exec command to run tasks in, or put/fetch files to, pods running on the Kubernetes container platform. + + + +Requirements +------------ +The below requirements are needed on the local Ansible controller node that executes this connection. + +- kubectl (go binary) + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsConfigurationComments
+
+ ca_cert + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_SSL_CA_CERT
+
var: ansible_kubectl_ssl_ca_cert
+
var: ansible_kubectl_ca_cert
+
+
Path to a CA certificate used to authenticate with the API.
+

aliases: kubectl_ssl_ca_cert
+
+
+ client_cert + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_CERT_FILE
+
var: ansible_kubectl_cert_file
+
var: ansible_kubectl_client_cert
+
+
Path to a certificate used to authenticate with the API.
+

aliases: kubectl_cert_file
+
+
+ client_key + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_KEY_FILE
+
var: ansible_kubectl_key_file
+
var: ansible_kubectl_client_key
+
+
Path to a key file used to authenticate with the API.
+

aliases: kubectl_key_file
+
+
+ kubectl_container + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_CONTAINER
+
var: ansible_kubectl_container
+
+
Container name.
+
Required when a pod contains more than one container.
+
+
+ kubectl_context + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_CONTEXT
+
var: ansible_kubectl_context
+
+
The name of a context found in the K8s config file.
+
+
+ kubectl_extra_args + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_EXTRA_ARGS
+
var: ansible_kubectl_extra_args
+
+
Extra arguments to pass to the kubectl command line.
+
Please be aware that this passes information directly on the command line and it could expose sensitive data.
+
+
+ kubectl_host + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_HOST
+
env:K8S_AUTH_SERVER
+
var: ansible_kubectl_host
+
var: ansible_kubectl_server
+
+
URL for accessing the API.
+
+
+ kubectl_kubeconfig + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_KUBECONFIG
+
var: ansible_kubectl_kubeconfig
+
var: ansible_kubectl_config
+
+
Path to a kubectl config file. Defaults to ~/.kube/config
+
+
+ kubectl_namespace + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_NAMESPACE
+
var: ansible_kubectl_namespace
+
+
The namespace of the pod
+
+
+ kubectl_password + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_PASSWORD
+
var: ansible_kubectl_password
+
+
Provide a password for authenticating with the API.
+
Please be aware that this passes information directly on the command line and it could expose sensitive data. We recommend using the file based authentication options instead.
+
+
+ kubectl_pod + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_POD
+
var: ansible_kubectl_pod
+
+
Pod name.
+
Required when the host name does not match pod name.
+
+
+ kubectl_token + +
+ - +
+
+ +
env:K8S_AUTH_TOKEN
+
env:K8S_AUTH_API_KEY
+
var: ansible_kubectl_token
+
var: ansible_kubectl_api_key
+
+
API authentication bearer token.
+
Please be aware that this passes information directly on the command line and it could expose sensitive data. We recommend using the file based authentication options instead.
+
+
+ kubectl_username + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_USERNAME
+
var: ansible_kubectl_username
+
var: ansible_kubectl_user
+
+
Provide a username for authenticating with the API.
+
+
+ validate_certs + +
+ - +
+
+ Default:
""
+
+
env:K8S_AUTH_VERIFY_SSL
+
var: ansible_kubectl_verify_ssl
+
var: ansible_kubectl_validate_certs
+
+
Whether or not to verify the API server's SSL certificate. Defaults to true.
+

aliases: kubectl_verify_ssl
+
+
+ + + + + + + + +Status +------ + + +Authors +~~~~~~~ + +- xuxinkun + + +.. hint:: + Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. diff --git a/galaxy.yml b/galaxy.yml index 52fd8541a9..d8dd928a27 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -14,8 +14,8 @@ documentation: '' homepage: '' issues: https://github.com/ansible-collections/kubernetes.core/issues license_file: LICENSE -name: core namespace: kubernetes +name: core readme: README.md repository: https://github.com/ansible-collections/kubernetes.core tags: diff --git a/plugins/lookup/k8s.py b/plugins/lookup/k8s.py index 7bfd1b79a8..278ed65438 100644 --- a/plugins/lookup/k8s.py +++ b/plugins/lookup/k8s.py @@ -25,6 +25,10 @@ short_description: Query the K8s API + author: + - Chris Houseknecht <@chouseknecht> + - Fabian von Feilitzsch <@fabianvf> + description: - Uses the OpenShift Python client to fetch a specific object by name, all matching objects within a namespace, or all matching objects for all namespaces, as well as information about the cluster.