Ansible AWX returns error: template error while templating string: unable to locate collection community.general

865 views Asked by At

I am working on a project using ansible AWX. In this project I have a check to see if all my microk8s pods are in the state running. Before I installed AWX I was testing all my plays on my linux vm. The following play worked fine on my linux vm but does not seem to work in ansible awx.

- name: Wait for pods to become running
  hosts: host_company_01
  tasks:
    - name: wait for pod status
      shell: kubectl get pods -o json
      register: kubectl_get_pods
      until: kubectl_get_pods.stdout|from_json|json_query('items[*].status.phase')|unique == ["Running"]
      timeout: 600

AWX gives me the following respons

[WARNING]: an unexpected error occurred during Jinja2 environment setup: unable
to locate collection community.general
fatal: [host_company_01]: FAILED! => {"msg": "The conditional check 'kubectl_get_pods.stdout|from_json|json_query('items[*].status.phase')|unique == [\"Running\"]' failed. The error was: template error while templating string: unable to locate collection community.general. String: {% if kubectl_get_pods.stdout|from_json|json_query('items[*].status.phase')|unique == [\"Running\"] %} True {% else %} False {% endif %}"}

I have looked at the error message and tried different possible solutions but without any effect.

First thing I tried was looking for the community.general collections in the ansible galaxy collection list. After I saw that it was found I tried downloading it once again, but this time with sudo. The collection was installed. After running my workflow template, the error message popped up again.

Second thing was trying to use different Execution environments, I thought that this was not going to make any difference but tried it anyways since someone online fixed a similar issue by changed EE.

Last thing I tried was trying to find a way around this play by building a new play with different commands. Sadly I was not able to build an other play that did what the original one did.

Since I can not build a play that fits my needs I came back at the error message to try and fix it.

0

There are 0 answers