Open
Description
Summary
The utils.is_playbook
function detects a yml file as a playbook when the non fqcn version of import_playbook
is used in the yaml file. When ansible.builtin.import_playbook
is used, ansible-lint considers this file not as a playbook.
Issue Type
- Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 0.1.dev2973 using ansible-core:2.18.4 ansible-compat:25.1.5 ruamel-yaml:0.18.10 ruamel-yaml-clib:0.2.12
- ansible installation method: pip
- ansible-lint installation method: pip
STEPS TO REPRODUCE
Create a Python file called test.py
and execute this. Without a fix for the is_playbook
function the 2nd playbook file is not considered a playbook although it is a playbook file. The 2 files that are verified are taken from the examples folder.
from ansiblelint.utils import is_playbook
non_fqcn_playbook_file="examples/playbooks/import-failed-syntax-check.yml"
print(f"Verify if {non_fqcn_playbook_file}, which uses import_playbook (non fqcn) is a playbook: {is_playbook(filename=non_fqcn_playbook_file)}")
fqcn_playbook_file="examples/playbooks/import_playbook_fqcn.yml"
print(f"Verify if {fqcn_playbook_file}, which uses ansible.builtin.import_playbook (fqcn) is a playbook: {is_playbook(filename=fqcn_playbook_file)}")
python3 test.py
Verify if examples/playbooks/import-failed-syntax-check.yml, which uses import_playbook (non fqcn) is a playbook: True
Verify if examples/playbooks/import_playbook_fqcn.yml, which uses ansible.builtin.import_playbook (fqcn) is a playbook: False
Desired Behavior
Executing the test.py script with a modified is_playbook
function should return True for both files
python3 test.py
Verify if examples/playbooks/import-failed-syntax-check.yml, which uses import_playbook (non fqcn) is a playbook: True
Verify if examples/playbooks/import_playbook_fqcn.yml, which uses ansible.builtin.import_playbook (fqcn) is a playbook: True
Actual Behavior
As can be seen above, the playbook file that uses fqcn import_playbook
is not considered a playbook while it should be and can be used as such with Ansible.
Metadata
Metadata
Assignees
Type
Projects
Status
No status