Skip to content

Commit

Permalink
Docs: no-relative-path rule doc edits (#2553)
Browse files Browse the repository at this point in the history
* no-relative-path rule doc edits

* chore: auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sorin Sbarnea <ssbarnea@redhat.com>
  • Loading branch information
3 people authored Oct 5, 2022
1 parent 503997b commit 655ca30
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/ansiblelint/rules/no_relative_paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ This rule checks for relative paths in the `ansible.builtin.copy` and `ansible.b
Relative paths in a task most often direct Ansible to remote files and directories on managed nodes.
In the `ansible.builtin.copy` and `ansible.builtin.template` modules, the `src` argument refers to local files and directories on the control node.

```{note}
For `copy` best location to store files is inside `files/` folder within the
playbook/role directory. For `template` the recommended location is `templates/`
folder, also within the playbook/role directory.
The recommended locations to store files are as follows:

- Use the `files/` folder in the playbook or role directory for the `copy` module.
- Use the `templates/` folder in the playbook or role directory for the `template` module.

For this reason, for `src`, you should either:
- Do not specify a path, or use a sub-folder of either `files/` or `templates/`.
- Use absolute path if the resources are above your Ansible playbook/role
These folders allow you to omit the path or use a sub-folder when specifying files with the `src` argument.

```{note}
If resources are outside your Ansible playbook or role directory you should use an absolute path with the `src` argument.
```

```{warning}
Avoid storing files or templates inside the same directory as your playbook or
tasks files. Doing this is a bad practice and also will generate linting
warning in the future. Imagine the user confusion if these files also happen
to be YAML.
Do not store resources at the same directory level as your Ansible playbook or tasks files.
Doing this can result in disorganized projects and cause user confusion when distinguishing between resources of the same type, such as YAML.
```

See [task paths](https://docs.ansible.com/ansible/latest/user_guide/playbook_pathing.html#task-paths) in the Ansible documentation for more information.
Expand Down

0 comments on commit 655ca30

Please sign in to comment.