ansible.kubernetes-modules
DEPRECATED
These modules are no longer recommended for use. Instead, use the k8s_raw and openshift_raw modules, which were added in Ansible 2.5.
ansible-kubernetes-modules
This module gives you access to the latest K8s modules.
You can include this role in a playbook, and any other plays, roles, and includes will be able to access the modules.
The modules are located in the library folder. Each module comes with full documentation on parameters and the structure of the returned data. However, not all modules have examples; only those with test data available.
If you encounter issues with any module or have suggestions, please report them at the OpenShift Rest Client repo.
For convenience, the k8s_common.py
and openshift_common.py
modules are found under module_utils. These are not part of an official Ansible release but are included in Ansible’s devel
branch. If you find a bug or want to make changes, kindly report issues and submit pull requests at the Ansible repo.
Requirements
- Ansible
- You need to have the OpenShift Rest Client installed on the host where the modules will run.
Installation and use
You can easily install the role using the Galaxy client:
$ ansible-galaxy install ansible.kubernetes-modules
After installation, include it in your playbook:
---
- hosts: localhost
remote_user: root
roles:
- role: ansible.kubernetes-modules
install_python_requirements: no
- role: hello-world
By referencing this role, the hello-world
role can deploy an application using the K8s modules. To see the actual contents of the role, look in the tests/roles folder.
Authenticating with the API
These modules communicate directly with the Kubernetes or OpenShift API. You don’t need the kubectl
or oc
CLI tools installed.
Module parameters
The OpenShift rest client needs a Kubernetes config file. Use these options to specify where to find the file and which context to use for authentication:
kubeconfig: Default path is
~/.kube/config
. Use this to specify a different file path.context: The name of the configuration context for authentication. If not provided, the current active context will be used.
You can also override settings in the config file with these parameters:
host: The URL of the API server.
ssl_ca_cert: The path to the Certificate Authority certificate file.
cert_file: The path to the server certificate file.
key_file: The path to the private key file.
api_key: The API token.
verify_ssl: Set to true or false. If false, SSL verification is disabled.
Environment Variables
Instead of passing authentication settings as parameters, you can use environment variables. The variable names start with K8S_AUTH_ followed by the variable name in uppercase. For example, key_file would be K8S_AUTH_KEY_FILE.
Role Variables
install_python_requirements: Set to true if you want to install the OpenShift Rest Client. Defaults to false and installs using
pip
.virtualenv: Provide the name of a virtualenv for installing
pip
packages.
License
Apache V2
ansible-galaxy install ansible.kubernetes-modules