Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Ansible-lint WARNING: Ignored exception from ArgsRule.matchtasks while processing #1343

Open
CompPhy opened this issue Oct 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@CompPhy
Copy link

CompPhy commented Oct 24, 2024

Ansible NetBox Collection version

v3.20.0

Ansible version

ansible [core 2.17.5]
  config file = /home/kshutt/projects/iaas/ansible.cfg
  configured module search path = ['/home/kshutt/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/kshutt/venv311/lib64/python3.11/site-packages/ansible
  ansible collection location = /home/kshutt/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/kshutt/venv311/bin/ansible
  python version = 3.11.10 (main, Sep  9 2024, 00:00:00) [GCC 11.5.0 20240719 (Red Hat 11.5.0-2)] (/home/kshutt/venv311/bin/python3.11)
  jinja version = 3.1.4
  libyaml = True

NetBox version

v4.0.5

Python version

3.11

Steps to Reproduce

  1. Create a task file with reference to the netbox.netbox.netbox_virtual_machine module:
    - name: "Make sure VM with name '{{ item }}' exists."
      netbox.netbox.netbox_virtual_machine:
        netbox_url: "{{ netbox_url }}"
        netbox_token: "{{ netbox_token }}"
        state: present
        data:
          name: "{{ item }}"
          site: "{{ netbox_site }}"
          cluster: "{{ netbox_cluster }}"
          vcpus: "{{ netbox_vcpus }}"  # This variable is a proper float type, which we have verified.
          memory: "{{ netbox_memory }}"  # This variable is a proper int type, which we have verified.
          disk: "{{ netbox_disk }}"  # This variable is a proper int type, which we have verified.
      register: vm_change
  2. Run ansible-lint against the file:
    ansible-lint my_role/tasks/create_vm.yml
  3. This warning is produced, indicating that an exception happened in parsing, and it's not going through proper lint checks.
    WARNING  Ignored exception from ArgsRule.matchtasks while processing my_role/tasks/create_vm.yml (tasks): 'vcpus'
    

Expected Behavior

One would expect ansible-lint to run correctly on a valid task file. The task in question does execute in our playbooks just fine. However, this warning means that it's not actually running any lint checks on the file.

Observed Behavior

WARNING  Ignored exception from ArgsRule.matchtasks while processing my_role/tasks/create_vm.yml (tasks): 'vcpus'
DEBUG    Ignored exception details
Traceback (most recent call last):
  File "/home/kshutt/venv311/lib64/python3.11/site-packages/ansiblelint/_internal/rules.py", line 94, in getmatches
    matches.extend(method(file))
                   ^^^^^^^^^^^^
  File "/home/kshutt/venv311/lib64/python3.11/site-packages/ansiblelint/rules/__init__.py", line 178, in matchtasks
    result = self.matchtask(task, file=file)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kshutt/venv311/lib64/python3.11/site-packages/ansiblelint/rules/args.py", line 188, in matchtask
    self._parse_failed_msg(failed_msg, task, module_name, file),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kshutt/venv311/lib64/python3.11/site-packages/ansiblelint/rules/args.py", line 234, in _parse_failed_msg
    option_value = task["action"]
                   ~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'vcpus'

The same warning happens on the memory and disk fields as well, possibly others? Oddly enough, the name, site, and cluster fields don't produce any warnings.

Commenting out the offending fields does allow ansible-lint to run without these warnings, but obviously would not have the correct results in our playbooks.

@CompPhy CompPhy added the bug Something isn't working label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant