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

Incorrect type guessing for an included playbook #640

Closed
bvergnaud opened this issue Nov 27, 2019 · 6 comments · Fixed by #641
Closed

Incorrect type guessing for an included playbook #640

bvergnaud opened this issue Nov 27, 2019 · 6 comments · Fixed by #641

Comments

@bvergnaud
Copy link

Issue Type

  • Bug report

Ansible and Ansible Lint details

➜ ansible --version
ansible 2.8.7
  config file = /home/bvergnaud/git/gitlab.infra.online.net/platform/ansible-playbooks/ansible.cfg
  configured module search path = ['/home/bvergnaud/git/gitlab.infra.online.net/platform/ansible-playbooks/library', '/home/bvergnaud/git/gitlab.infra.online.net/platform/ansible-playbooks/library/foreman/plugins/modules']
  ansible python module location = /home/bvergnaud/.local/share/virtualenvs/ansible-playbooks-VBzdj4yE/lib/python3.8/site-packages/ansible
  executable location = /home/bvergnaud/.local/share/virtualenvs/ansible-playbooks-VBzdj4yE/bin/ansible
  python version = 3.8.0 (default, Oct 23 2019, 18:51:26) [GCC 9.2.0]

~/git/gitlab.infra.online.net/platform/ansible-playbooks on  master [$!?] via 🐍 v3.8.0 (ansible-playbooks-VBzdj4yE) 
➜ ansible-lint --version
ansible-lint 4.2.0rc1
  • ansible installation method: pip
  • ansible-lint installation method: pip

Desired Behaviour

When importing a playbook from within another playbook, ansible-lint should properly guess that it is a type playbook.

Actual Behaviour (Bug report only)

When you include a playbook in the pre-tasks sections (we need that secondary playbook to play before the roles) the linter guess its type as 'pre_tasks', and reports the following error multiple times in my case (I didn't manage to find what the number of error is based on): Error trying to append skipped rules: RuntimeError('Unexpected file type: pre_tasks').

Example playbook1.yml :

---
- name: Do something
  hosts: "some_host"
  pre_tasks:
    - name: Do something before the roles
      include: playbook2.yml

  roles:
    - role1

The included playbook2.yml is another playbook right next to the first one, and could contain anything.
The error does not cause the return code to change which is lucky in my case as I'm trying to bake it in the pre-commit routine.

@webknjaz
Copy link
Member

@bvergnaud did it work in 4.1?

@bvergnaud
Copy link
Author

Yes it did. However the 4.1 will not install from source, in pre-commit.
#590

@webknjaz
Copy link
Member

@ssbarnea @awcrosby ^

@awcrosby
Copy link
Contributor

awcrosby commented Dec 3, 2019

I see this was introduced in #528, the skip logic does not check for a file_type of pre_tasks. #641 was added to fix this.

@awcrosby
Copy link
Contributor

awcrosby commented Dec 3, 2019

@bvergnaud ansible-lint 4.2.0rc2 has this fix included

@bvergnaud
Copy link
Author

Wonderful. Thanks a lot. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants