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

FQCN Import tasks do not import files for checking #1842

Closed
ryaner opened this issue Feb 3, 2022 · 3 comments
Closed

FQCN Import tasks do not import files for checking #1842

ryaner opened this issue Feb 3, 2022 · 3 comments
Labels

Comments

@ryaner
Copy link
Contributor

ryaner commented Feb 3, 2022

Summary

Ansible lint is not doing the normal import behaviour is the import_ tasks are specified with the FQCN format in roles. The only user facing message is that the task is not named as highlighted on #1615.

The behaviour is different playbooks and it does load and properly validate those files.

The issue relates to play_children and how the tasks are getting compared as they aren't normalized when they hit it. Adding in a simple "ansible.builtin.import_tasks": _include_children, line here does trigger the file to be loaded but likely isn't the proper solution.

Issue Type
  • Bug Report
Ansible and Ansible Lint details
# ansible --version
ansible 2.10.17
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible_base-2.10.17-py3.9.egg/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]

# ansible-lint --version
ansible-lint 5.3.2 using ansible 2.10.17
  • ansible installation method: one of source, pip
  • ansible-lint installation method: one of source, pip
OS / ENVIRONMENT

Debian 11

STEPS TO REPRODUCE

Case 1 playbooks

fqcn_failure.yml

---
- hosts: all
  tasks:
    - ansible.builtin.import_tasks: second.yml

second.yml

---
invalid_yaml

Case 2 playbooks

/etc/ansible/roles/lint/tasks/main.yml

---
- ansible.builtin.import_tasks: second.yml

/etc/ansible/roles/lint/tasks/second.yml

---
invalid_yaml
Desired Behaviour

Import cases operate consistently.

Actual Behaviour

Case 1 - second.yml imported and checked correctly

# ansible-lint working.yml
WARNING  Overriding detected file kind 'yaml' with 'playbook' for given positional argument: working.yml
WARNING  Listing 1 violation(s) that are fatal
syntax-check: included task files must contain a list of tasks
second.yml:2:1 ERROR! included task files must contain a list of tasks

The error appears to be in '/ansible_lint_fqcn_test_case/second.yml': line 2, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
invalid_yaml
^ here

Case 2 - no import of invalid second.yml in the role, only the unnamed-task error.

# ansible-lint /etc/ansible/roles/lint/tasks/main.yml
WARNING  Listing 1 violation(s) that are fatal
unnamed-task: All tasks should be named
etc/ansible/roles/lint/tasks/main.yml:2 Task/Handler: import_tasks  second.yml
@ryaner ryaner added bug new Triage required labels Feb 3, 2022
@relrod relrod removed the new Triage required label Feb 7, 2022
@relrod
Copy link
Member

relrod commented Feb 7, 2022

A PR would be welcomed to improve this behavior.

@ryaner
Copy link
Contributor Author

ryaner commented Feb 7, 2022

#1854
Some comments there with another possible fix too other that what I coded.

@ryaner
Copy link
Contributor Author

ryaner commented Mar 2, 2022

Fixing with #1854.

@ryaner ryaner closed this as completed Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants