Skip to content

mock_roles does not work with collection role name #4973

@jennydaman

Description

@jennydaman
Summary

The configuration mock_roles does not work with roles from collections, i.e. roles with two . characters in their name.

Issue Type
  • Bug Report
OS / ENVIRONMENT

Tested in two different environments:

ansible-lint 26.1.1 using ansible-core:2.20.2 ansible-compat:25.12.0 ruamel-yaml:0.19.1 ruamel-yaml-clib:0.2.15

Also

ansible-lint 25.8.2 using ansible-core:2.20.0 ansible-compat:25.12.0 ruamel-yaml:0.18.16 ruamel-yaml-clib:0.2.14
  • ansible installation method: pip, nixpkgs
  • ansible-lint installation method: pip, nixpkgs
STEPS TO REPRODUCE
cd $(mktemp -d test-ansible-lint-XXXXXXXX -p '')

cat > .ansible-lint.yml << EOF
---
mock_roles:
  - one.two
  - one.two.three
EOF

cat > my_playbook.yml << EOF
---
- name: Testing ansible-lint
  hosts: all
  roles:
    - one.two
    - one.two.three
EOF

ansible-lint
Desired Behavior
Passed: 0 failure(s), 0 warning(s) on 2 files. Last profile that met the validation criteria was 'production'.
Actual Behavior
WARNING  Listing 1 violation(s) that are fatal
syntax-check[specific]: the role 'one.two.three' was not found in /tmp/test-ansible-lint-nmW1zPN0/roles:/tmp/test-ansible-lint-nmW1zPN0/.ansible/roles:/home/jenni/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/tmp/test-ansible-lint-nmW1zPN0
my_playbook.yml:5:7


# Rule Violation Summary

  1 syntax-check profile:min tags:core,unskippable

Failed: 1 failure(s), 0 warning(s) on 2 files.

Note

Role names with one . work, you can try this by running sed -i.bak '/one.two.three/d' my_playbook.yml followed by ansible-lint

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugnewTriage required

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions