How to install network related module in AWX version 23.0

hi guys,

Again some playbook issue in AWX 23.0.0 while all playbook are running smoothly in AWX 9.0 version

It seems that the network related modules are missing in AWX 23.0.0 version, my playbook is running against Extreme SLX switch

Errors are as below

ERROR! couldn't resolve module/action 'slxos_command'. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in '/runner/project/playbooks/platform/show_version.yml': line 10, column 11, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
    - block:
        - name: show version [SLX]
          ^ here

So it seems that I need to install this module below to make it work

https://galaxy.ansible.com/extreme/slxos

But anyone can recommend any documentation or procedure to guide me through the procedure

Thanks

@AWX

I have managed to install this module with the command

ansible-galaxy collection install community.network

in awx-operator-controller-manager container,

I think I can even see this module

bash-4.4$ pwd
/opt/ansible/.ansible/collections/ansible_collections/community/network/plugins/modules

bash-4.4$ ls -al | grep slxos_command
-rw-r--r--.  1 ansible root   7382 Sep 22 20:32 slxos_command.py
bash-4.4$

But still when I run this playbook, I have errors

Parsed /runner/inventory/hosts inventory source with script plugin

redirecting (type: modules) ansible.builtin.slxos_command to community.network.slxos_command**

ERROR! couldn't resolve module/action 'slxos_command'. This often indicates a misspelling, missing collection, or incorrect module path.

My playbooks source code is below

name: Show version
  hosts: PE
  gather_facts: no
  collections:
    - community.network
  tasks:
    - name: Run show version on remote devices
      slxos_command:
        commands: show version
      when:
        - (inventory_hostname in groups['SLX'])
      changed_when: false
      ignore_errors: true
      no_log: true
      register: output_slx

    - name: Results [SLX]
      debug:
        msg: "{{ output_slx.stdout_lines[0] }}"
      when: output_slx.stdout_lines[0] is defined

Hi @mapleos1123, glad to see you are finding the forum useful!

Let me share a couple of tips on using the forum to make it easier for people to help out:

I just edited your messages to include the code blocks for the playbook section, this makes it easier to read as it keeps the playbook format and spacing.

When composing your next messages, you can select the playbook section of text you copy/pasted and use the </> button in the tool-bar right at the top of the message window where you are typing, this will automatically put it in the box you see in the messages above. Here is a screen capture of me doing it for your message above:

And if you get to a point where you consider a post by someone helped to solve the issue, please tick the check-box below their message to mark it as the solution to help other users find the reply faster!

1 Like

Does the collection appear when you search for it like this?

ansible-galaxy collection list | grep community.network
community.network             5.0.0  

Do you get the same error if you use a fully qualified module name, community.network.slxos_command like this?

name: Show version
  hosts: PE
  gather_facts: no
  collections:
    - community.network
  tasks:
    - name: Run show version on remote devices
      community.network.slxos_command:
        commands: show version
      when:
        - (inventory_hostname in groups['SLX'])
      changed_when: false
      ignore_errors: true
      no_log: true
      register: output_slx

    - name: Results [SLX]
      debug:
        msg: "{{ output_slx.stdout_lines[0] }}"
      when: output_slx.stdout_lines[0] is defined
1 Like

hi @Leo thanks for the useful tip, I will follow the guide :slight_smile:

hi @chris

Thanks a lot for your time

I did not see ‘list’ option in this command

bash-4.4$ ansible-galaxy collection list | grep community.network
usage: ansible-galaxy collection [-h] COLLECTION_ACTION ...
ansible-galaxy collection: error: argument COLLECTION_ACTION: invalid choice: 'list' (choose from 'init', 'build', 'publish', 'install')
bash-4.4$

I am not sure if I install this collection in a correct way or not. What I did was to log into awx-operator-controller-manager container

kubectl exec -it awx-operator-controller-manager-65ddfcbf7d-hb49j -n awx

and installed with this command

ansible-galaxy collection install community.network

After that command, I can see the path seems contain the package I have installed

bash-4.4$ pwd
/opt/ansible/.ansible/collections/ansible_collections/community/network

Am I installing the collection in a correct way ? Since I did not find in AWX GUI to download/import Ansible collection

And yes, I have tried to use fully qualified module name in the playbook as well, but it the same

1 Like

Perhaps you have an old version that doesn’t support list, or perhaps the collection is not installed, what does it return without the grep:

ansible-galaxy collection list

You can check the ansible-galaxy version like this:

ansible-galaxy --version 
ansible-galaxy [core 2.15.4]
  config file = /home/chris/.ansible.cfg
  configured module search path = ['/home/chris/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/chris/.local/pipx/venvs/ansible/lib/python3.11/site-packages/ansible
  ansible collection location = /home/chris/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/chris/.local/bin/ansible-galaxy
  python version = 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] (/home/chris/.local/pipx/venvs/ansible/bin/python)
  jinja version = 3.1.2
  libyaml = True

Sorry I know nothing about AWX so can’t help with that, perhaps you could use Ansible to install the collection?

@mapleos1123
If your project is stored on SCM (Git or SubVersion), create collections/requirements.yml on project root and add following content, then sync project on AWX. This will download and install specified collections during project sync:

---
collections:
  - name: community.network

If your project type is Manual, adding collections/requirements.yml does not help. In this case, you should create your own custom container image by Ansible Builder. I have a guide for this topic: https://github.com/kurokobo/awx-on-k3s/tree/main/builder

Background:

In the recent version of AWX, your playbook will launched in isolated container called Execution Environment. This is completely different architecture from AWX 9.x, so you should know what EE is: What's new in Ansible Automation Platform 2: automation execution environments

So EE is exactly where collections have to be placed. Adding collections/requirements.yml on your project makes collections to be transferred to EE with your playbook, and building custom EE is the way to make collections available on EE without transfferring it.

4 Likes

@kurokobo

Thanks a lot, this works, although I do have some other issues popping up, there is no any missing module related alarm

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.