# Ansible with k8s-module example

**URL:** <https://forum.ansible.com/t/ansible-with-k8s-module-example/29635>\
**Category:** Ansible Project\
**Tags:** awx, kubernetes\
**Created:** [February 6, 2019, 9:04pm UTC](https://forum.ansible.com/t/ansible-with-k8s-module-example/29635 "2019-02-06T21:04:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kylix\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/c37758/32.png) [@Kylix\_Kumar](https://forum.ansible.com/u/Kylix_Kumar)\
**Post date:** [February 6, 2019, 9:04pm UTC](https://forum.ansible.com/t/ansible-with-k8s-module-example/29635/1 "2019-02-06T21:04:55Z")

</div>

Hi All,

Ansible k8s module ( [https://docs.ansible.com/ansible/latest/modules/k8s\_module.html#k8s-module](https://docs.ansible.com/ansible/latest/modules/k8s_module.html#k8s-module) ) have many environments like :

api\_key ---- K8S\_AUTH\_API\_KEY environment variable.  
cert\_file — K8S\_AUTH\_CERT\_FILE environment variable.  
context — K8S\_AUTH\_CONTEXT environment variable.  
host — K8S\_AUTH\_HOST environment variable.  
key\_file — K8S\_AUTH\_HOST environment variable.  
kubeconfig — K8S\_AUTH\_KUBECONFIG environment variable.  
password — K8S\_AUTH\_PASSWORD environment variable.  
ssl\_ca\_cert — K8S\_AUTH\_SSL\_CA\_CERT environment variable.  
username ---- K8S\_AUTH\_USERNAME environment variable.  
verify\_ssl ---- K8S\_AUTH\_VERIFY\_SSL environment variable.

Do any body use these environmental variables in the playbook ? Do have any example or sample playbook with one or many environment variable. I’m looking very specially for kubeconfig — K8S\_AUTH\_KUBECONFIG environment variable to use it in ansible playbooks ( and also in Ansible AWX )

Please help.

---

<div class="post-metadata">

**Author:** ![Kylix\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/c37758/32.png) [@Kylix\_Kumar](https://forum.ansible.com/u/Kylix_Kumar)\
**Post date:** [February 6, 2019, 9:37pm UTC](https://forum.ansible.com/t/ansible-with-k8s-module-example/29635/2 "2019-02-06T21:37:58Z")

</div>

- module authors for some sights and help 🙂

---

<div class="post-metadata">

**Author:** ![willthames](https://avatars.discourse-cdn.com/v4/letter/w/8dc957/32.png) [@willthames](https://forum.ansible.com/u/willthames)\
**Post date:** [February 7, 2019, 12:05am UTC](https://forum.ansible.com/t/ansible-with-k8s-module-example/29635/3 "2019-02-07T00:05:21Z")

</div>

Yes, I've used K8S\_AUTH\_KUBECONFIG and K8S\_AUTH\_CONTEXT

K8S\_AUTH\_KUBECONFIG=~/.kube/another\_kube\_config ansible-playbook kubernetes.yml  
K8S\_AUTH\_CONTEXT=minikube ansible-playbook do\_something\_with\_minikube.yml

There was an issue with early 2.7 Ansible that you needed to set both variables but that was fixed with [https://github.com/ansible/ansible/pull/47496](https://github.com/ansible/ansible/pull/47496) which seems to be in 2.7.1 according to git tag --contains

Will

---

<div class="post-metadata">

**Author:** ![Kylix\_Kumar](https://avatars.discourse-cdn.com/v4/letter/k/c37758/32.png) [@Kylix\_Kumar](https://forum.ansible.com/u/Kylix_Kumar)\
**Post date:** [February 7, 2019, 1:04am UTC](https://forum.ansible.com/t/ansible-with-k8s-module-example/29635/4 "2019-02-07T01:04:45Z")

</div>

Thanks Will. Appreciate your help on this.

Thanks.

Regards,  
kylix3511

[Email : kylix3511@gmail.com](mailto:kylix3511@gmail.com)
