Python 2 is End of life and not supported by Ansible. Also, kubernetes.core collection is supported on Python3 ( https://github.com/ansible-collections/kubernetes.core#python-support). I would recommend you upgrade to the latest Python version. After installing the latest Python 3 version use
``` --- - hosts: localhost vars: ansible_python_interpreter: /Path/to/bin/python3 tasks: ... ``` or ``` export ANSIBLE_PYTHON_INTERPRETER=/path/to/bin/python3 ``` then run the playbook. Apart from that `--syntax-check` would provide syntax errors for YAML files, not for the actual module that is being invoked. On Wed, Jul 20, 2022 at 6:12 PM DEEPANSHU DANG <[email protected]> wrote: > Hi team, > > I'm running ansible on centos 7 in which python 2 coming by default and > some dependencies like yum etc is depended on that. > > When Ansible is install it picking the default python2 as INTERPRETER > > Ansible --version > ansible 2.9.27 config file = /etc/ansible/ansible.cfg configured module > search path = [u'/home/centos/.ansible/plugins/modules', > u'/usr/share/ansible/plugins/modules'] ansible python module location = > /usr/lib/python2.7/site-packages/ansible executable location = > /usr/bin/ansible *python version = 2.7.5* (default, Jun 28 2022, > 15:30:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] > > With the following link: I have set the Python INTERPRETER as Environment > > IniSection [defaults] > Key interpreter_python > EnvironmentVariable ANSIBLE_PYTHON_INTERPRETER > <https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_PYTHON_INTERPRETER> > Variablesname ansible_python_interpreter > > But when I try executing kubernetes.core.helm: modules its throwing me an > error: > > TASK [adding] > ************************************************************************************************************************************************************************************************* > fatal: [ansible_host="HOST IP"]: FAILED! => {"msg": "Unable to import > kubernetes.core.helm due to invalid syntax"} > > here is my sample playbook > --- > - hosts: host > gather_facts: true > tasks: > - name: Install Nginx Chart > kubernetes.core.helm: > name: nginx-server > namespace: default > chart_ref: bitnami/nginx > > on the other hand when i check the syntax of ansible playbook following > the command > > ansible-playbook <playbook.yaml> --syntax-check > > response is ok > > Can you please assist me how can we fix this issue > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/25b7335d-b609-454f-8451-d6f516a95364n%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/25b7335d-b609-454f-8451-d6f516a95364n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Thanks, Abhijeet Kasurde -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAFwWkHpLNrMjao1A%2BdXBc9N_EbrA%2BsmAB-5aDu%2BFJxScW7JFRQ%40mail.gmail.com.
