Awx fails as it can't find a module in a task that should actually be skipped

Hi,
I have a playbook that uses the newrelic.newrelic-infra role for installing new relic. The playbooks just work fine when I manually run it.
This is the part of the playbook with the role we are using.

- name: Install New Relic 
  hosts: xxx
  become: yes
  roles:
    - role: newrelic.newrelic-infra
      vars:
        nrinfragent_logging:
          - name: httpd-logs
            source_type: /var/log/httpd/error_log
            source_value: FILE 
            custom_attributes:
              application: xxx
              service: httpd
              logtype: httpd_error
        log_file: /var/log/newrelic-infra/newrelic-infra.log
        verbose: 0
        nrinfragent_config:
          license_key: xxxx
        custom_attributes:
          environment: dev

However, when I try to run the playbook through awx, it fails giving error

ERROR! couldn't resolve module/action 'win_chocolatey'. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in '/runner/requirements_roles/newrelic.newrelic-infra/tasks/install_dist_pkgs.yml': line 143, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: install agent (windows)
  ^ here

The code that is mentioned in the error is

- name: install agent (windows)
  win_chocolatey:
    name: newrelic-infra
    state: "{{ nrinfragent_state }}"
    version: "{{ nrinfragent_choco_version | default(omit) }}"
  when:
    - nrinfragent_os_name == 'windows'

Ideally, awx should skip the task as it should be executed only on windows machine. But I’m having a RHEL machine, so it’s unable to find the win_chocolatey module. Can someone help me here on why awx doesn’t skip it when the manual playbook run is fine?
awx

Thanks

newrelic.newrelic-infra appears to be unmaintained and deprecated in favour of newrelic.newrelic_install, so you might be better off spending your time getting that role to work rather than continuing with this one.

The difference between your local runs and the ones in AWX is that even though it doesn’t end up being used, you have the win_chocolatey module (part of the chocolatey.chocolatey collection) installed. When Ansible does the initial validation of actions during parsing it does not have any way to know that the task will end up being skipped. All it knows is that the code it’s parsing asks for an action that does not exist, which is a fatal error.

1 Like

Thank you so much for the reply :slight_smile:
I guess then I’ll update it to use newrelic.newrelic_install and try
Just out of curiosity, so probably then when running the playbooks manually, ansible doesn’t parse it fully first(since the role was working fine and had the new relic setup up and running)?

The issue is that the EE you’re using in AWX doesn’t have the chocolatey.chocolatey collection installed, so the play fails before it even starts.

When you run ansible manually/locally, you must have the chocolatey.chocolatey collection installed (which you will if you have installed the “batteries included” ansible package or by installing the collection through ansible-galaxy), because otherwise it would fail exactly the same way.

Thanks for the help and clarification.
I tried using the newerlic.newrelic_install in place of the older role(newrelic.newrelic-infra) and it works fine. :+1:

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