ansible / ansible-lint

ansible-lint checks playbooks for practices and behavior that could potentially be improved and can fix some of the most common ones for you
https://ansible.readthedocs.io/projects/lint/
GNU General Public License v3.0
3.51k stars 664 forks source link

'with_community.general.filetree' is not a valid attribute for a Task #4304

Open 4wk- opened 2 months ago

4wk- commented 2 months ago
SUMMARY

ansible-lint is complaining about attribute with_community.general.filetree not being valid. However, it's in Ansible official documentation. cf examples.

image

Am I missing something?

ISSUE TYPE
OS / ENVIRONMENT

Debian 12.6 in wsl2

$ ansible-lint --version
ansible-lint 24.7.0 using ansible-core:2.17.2 ansible-compat:24.7.0 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8
STEPS TO REPRODUCE
---
- name: testing123
  hosts: all
  become: yes
  gather_facts: no
  tasks:

    - name: Testing filetree
      ansible.builtin.template:
        src: "{{ item.path }}"
        dest: "/tmp/"
        owner: root
        group: root
        mode: '644'
      with_community.general.filetree: "templates/"
      when: item.state == 'file'
DESIRED BEHAVIOR

ansible-lint should not complain about with_community.general.filetree.

ACTUAL BEHAVIOR
$ ansible-lint zplay.yml
WARNING  Listing 1 violation(s) that are fatal
syntax-check[specific]: 'with_community.general.filetree' is not a valid attribute for a Task
zplay.yml:11:7

                  Rule Violation Summary
 count tag                    profile rule associated tags
     1 syntax-check[specific] min     core, unskippable

Failed: 1 failure(s), 0 warning(s) on 1 files. Profile 'production' was required.
cavcrosby commented 2 months ago

I was able to reproduce this when deleting the community.general collection from all directories within Ansible's collections_path. Can you check to see if the collection is installed, and that the collections_path configuration is set appropriately to find the collection?

leonardgerardatomicmachinescom commented 4 weeks ago

Is the linter dependent on the specific ansible that is installed in the system? (we run the linter in CI, which doesn't install ansible)

cavcrosby commented 3 weeks ago

@leonardgerardatomicmachinescom I believe ansible-lint will work with versions of ansible/ ansible-core that meet the version constraint ansible-core>=2.13.0. I'm basing this on the "requirements.txt" file used to specify runtime dependencies, as shown below.

https://github.com/ansible/ansible-lint/blob/7b9749373a4282d2fe6fc15a6ce3e65d41f7efae/.config/requirements.in#L3