Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
496 views
in Technique[技术] by (71.8m points)

Ansible collection not detected when running playbook on AWX

I use modules from the collection netapp.ontap in my ansible playbook which works perfectly fine when run using ansible-playbook command. However, when run from AWX, it fails to detect the collection and immediately throws an errors that it cannot detect the ansible module/collection. I even tried to re-install the collection from the playbook itself but with no luck.

The ansible collection is confirmed to be installed as it already works fine when run outside AWX.

The host is running ansible 2.10.4.

Here is my playbook:

---
- hosts: all
  gather_facts: yes
 
  collections:
  - netapp.ontap

  tasks: 
   
  - name: Install Netapp Collection from Ansible Galaxy
    shell: ansible-galaxy collection install netapp.ontap


  - name: Run Task
    import_tasks: tasks/hil.yml

Task:

- name: 'Gather SVMs'
  netapp.ontap.na_ontap_info:
    state: info
    hostname: "{{ netapp_hostname }}"  
    username: "{{ netapp_username }}"
    password: "{{ netapp_hv_password }}"
    gather_subset:
    - vserver_info

Error from AWX:

SSH password: 
Vault password: 
ERROR! couldn't resolve module/action 'netapp.ontap.na_ontap_info'. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in '/tmp/awx_421_gey54bdw/project/tasks/hil.yml': line 6, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: 'Gather SVMs'
  ^ here
This one looks easy to fix. It seems that there is a value started
with a quote, and the YAML parser is expecting to see the line ended
with the same kind of quote. For instance:
    when: "ok" in result.stdout
Could be written as:
   when: '"ok" in result.stdout'
Or equivalently:
   when: "'ok' in result.stdout"

Update: I created a collections/requirements.yml file, with the below details but now AWX fails the task itself.

collections/requirements.yml

collections:
   name: https://github.com/ansible-collections/netapp.git
   type: git

Error:

"/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/tasks.py", 
line 1279, in run self.pre_run_hook(self.instance, private_data_dir) File 
"/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/tasks.py", 
line 1862, in pre_run_hook sync_task.run(local_project_sync.id) File 
"/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/tasks.py", 
line 698, in _wrapped return f(self, *args, **kwargs) File 
"/var/lib/awx/venv/awx/lib/python3.6/site-packages/awx/main/tasks.py", 
line 1444, in run raise AwxTaskError.TaskError(self.instance, rc) 
Exception: project_update 435 (failed) encountered an error (rc=2), please 
see task stdout for details.
question from:https://stackoverflow.com/questions/65918833/ansible-collection-not-detected-when-running-playbook-on-awx

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...