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-builtins: add documentation #2412

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/ansiblelint/rules/fqcn_builtins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# fqcn-builtins

This rule checks that playbooks use the fully qualified collection name (FQCN) for modules in the `ansible.builtin` collection.

## Problematic Code

```yaml
---
- name: Example playbook
hosts: all
tasks:
- name: Shell
shell: echo # <- This does not use the FQCN for the shell module.
```

## Correct Code

```yaml
---
- name: Example playbook
hosts: all
tasks:
- name: Shell
ansible.builtin.shell: echo # <- This uses the FQCN for the shell module.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this changes the meaning, to preserve the same meaning it would have to be ansible.legacy.shell

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting that @bcoca

I'm going to update the examples here to use one of the ansible.builtin modules. I could be wrong in my thinking but it seems like we wouldn't want users to go with the ansible.legacy.shell module so putting it in the "Correct Code" example might not be the right thing to do.

@ssbarnea I actually got this from the test at:

Do you think this might need an update based on Brian's comment as well? Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the difference between legacy and builtin is subtle and most users won't care, but the ones that do ... will find themselves with an unexpected change in behavior. legacy allows local overrides while builtin does not, most people don't have local overrides, but those that do, depend on them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bcoca Any documentation links pointing to difference between the two that we can include in this markdown file?

In the end we just give an example of "modernizing" the code, that does not mean that the right answer is always appending "ansible.builtins." prefix. Still, adding an extra note/link regarding the nuances could only be seen as beneficial, convincing user to make a more informed decision.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-( no, cannot find it ever making the docs

```