Hi,
I’m using Ansible to deploy an application to a Kubernetes cluster. I followed all the steps listed in the official Ansible docs at: https://docs.ansible.com/ansible-container/deploy_kubernetes.html#deployment. My Ansible versions and kubectl versions plus all other dependencies are as they would be if all steps in the docs were followed.
All steps were successful until the final step, which failed with Error 1 below. I ‘fixed’ this error by copying the library .py files from example/ansible/roles/example-kubernetes/library/.py to container/shipit/kubernetes/modules/*.py. This then gave me Error 2. I guess I’m missing some library but I can’t figure out which one. Any help much appreciated.
Error 1
[ibmcloud@mcdg-centos-71939519 ansible]$ ansible-playbook shipit-kubernetes.yml -e “playbook_debug=true”
[WARNING]: provided hosts list is empty, only localhost is available
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
The error appears to have been in ‘/home/ibmcloud/ansible-container/example/ansible/roles/example-kubernetes/tasks/main.yml’: line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- kube_service:
^ here
The error appears to have been in ‘/home/ibmcloud/ansible-container/example/ansible/roles/example-kubernetes/tasks/main.yml’: line 2, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- kube_service:
^ here
**Error 2**
$ ansible-playbook shipit-kubernetes.yml
[WARNING]: provided hosts list is empty, only localhost is available
PLAY [Deploy example to kubernetes] *******************************************
TASK [example-kubernetes : kube_service] ***************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: NameError: global name 'KubeAPI' is not defined
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_0l6WqQ/ansible_module_kube_service.py\", line 213, in <module>\n main()\n File \"/tmp/ansible_0l6WqQ/ansible_module_kube_service.py\", line 210, in main\n manager.exec_module()\n File \"/tmp/ansible_0l6WqQ/ansible_module_kube_service.py\", line 112, in exec_module\n self.api = KubeAPI(self.module)\nNameError: global name 'KubeAPI' is not defined\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}
NO MORE HOSTS LEFT *************************************************************
to retry, use: --limit @shipit-kubernetes.retry