+
Skip to content

ansible-lint -r/-R disable embedded rules #4747

@Lucas-C

Description

@Lucas-C

ansible-lint documentation recommends to install custom rules as packages.

However, several online tutorials suggest to use the -r CLI flag to specify a directory for ansible-lint to pick up user-defined custom rules.

First (suggestion), when using -r ./custom-rules/, I think it would be very handy to have a warning produced informing the user that embedded rules are disabled.

Second (actual bug), there is also a -R flag, documented like this in 25.8.2 in the --help output:

  -r RULESDIR, --rules-dir RULESDIR
                        Specify custom rule directories. Add -R to keep using embedded rules from /home/lucas_cimon/.local/share/virtualenvs/chezsoi/lib/python3.10/site-packages/ansiblelint/rules
  -R                    Keep default rules when using -r

However, based on some basic test with the embedded risky-file-permissions rule, even when using -R the embedded rules are disabled.

Issue Type
  • Bug Report
OS / ENVIRONMENT

Ubuntu 22.04

ansible-lint --version
ansible-lint 25.8.2 using ansible-core:2.17.13 ansible-compat:25.8.1 ruamel-yaml:0.18.14 ruamel-yaml-clib:0.2.12
  • ansible installation method: pip
  • ansible-lint installation method: pip
STEPS TO REPRODUCE
mkdir /tmp/bugrepro
cd /tmp/bugrepro
mkdir -p roles/bugrepro/tasks
cat <<EOF >roles/bugrepro/tasks/main.yaml
- name: Create /tmp/dummy
  ansible.builtin.file:
    path: /tmp/dummy
    state: directory
> EOF
ansible-lint  # correctly reports an issue with the risky-file-permissions rule

mkdir custom-rules
ansible-lint -R custom-rules  # does not report any issue
Desired Behavior
  1. when using -R, embedded rules should not be disabled (actual bug)
  2. when using -r, a warning should be produced to recommend to switch to -R (suggestion)
Actual Behavior

When using -R, embedded rules are disabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载