forked from ansible/ansible-lint
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace template-instead-of-copy with avoid-implicit[copy-content] ru…
…le (ansible#2512) Fixes: ansible#2501
- Loading branch information
Showing
7 changed files
with
59 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# avoid-implicit | ||
|
||
This rule identifies the use of dangerous implicit behaviors, often also | ||
undocumented. | ||
|
||
This rule will produce the following type of error messages: | ||
|
||
- `avoid-implicit[copy-content]` is not a string as [copy](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html#synopsis) | ||
modules also accept these, but without documenting them. | ||
|
||
## Problematic Code | ||
|
||
```yaml | ||
--- | ||
- name: Example playbook | ||
hosts: localhost | ||
tasks: | ||
- name: Write file content | ||
ansible.builtin.copy: | ||
content: { "foo": "bar" } # <-- should use explicit jinja template | ||
dest: /tmp/foo.txt | ||
``` | ||
## Correct Code | ||
```yaml | ||
--- | ||
- name: Example playbook | ||
hosts: localhost | ||
tasks: | ||
- name: Write file content | ||
vars: | ||
content: { "foo": "bar" } | ||
ansible.builtin.copy: | ||
content: "{{ content | to_json }}" # explicit better than implicit! | ||
dest: /tmp/foo.txt | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.