-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve no-changed-when rule (#3050)
Co-authored-by: bluikko <[email protected]>
- Loading branch information
Showing
6 changed files
with
97 additions
and
152 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
- name: Fixture for no-changed-when (fail with 3 occurrences) | ||
hosts: all | ||
tasks: | ||
- name: Register command output, but cat still does not change anything | ||
ansible.builtin.command: cat {{ my_file | quote }} | ||
register: my_output | ||
- name: Block level 1 | ||
block: | ||
- name: Block level 2 | ||
block: | ||
- name: Basic command task, should fail | ||
ansible.builtin.command: cat my_file | ||
- name: Basic shell task, should fail | ||
shell: cat my_file # noqa: fqcn command-instead-of-shell |
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,23 @@ | ||
--- | ||
- name: Fixture for no-changed-when (pass) | ||
hosts: all | ||
tasks: | ||
- name: Handle command output with return code # noqa: command-instead-of-shell | ||
ansible.builtin.command: cat {{ my_file | quote }} | ||
register: my_output | ||
changed_when: my_output.rc != 0 | ||
|
||
- name: Handle shell output with return code # noqa: command-instead-of-shell | ||
ansible.builtin.shell: cat {{ my_file | quote }} | ||
register: my_output | ||
changed_when: my_output.rc != 0 | ||
|
||
- name: Handle shell output with false changed_when # noqa: command-instead-of-shell | ||
ansible.builtin.shell: cat {{ my_file | quote }} | ||
register: my_output | ||
changed_when: false | ||
|
||
- name: Command with argument | ||
command: createfile.sh # noqa: fqcn | ||
args: | ||
creates: /tmp/????unknown_files???? |
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