Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor command-instead-of-shell fixtures in standalone examples (#3210
- Loading branch information
Showing
5 changed files
with
108 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
- name: Fixture | ||
hosts: localhost | ||
tasks: | ||
- name: Shell no pipe | ||
ansible.builtin.shell: | ||
cmd: echo hello | ||
changed_when: false | ||
|
||
- name: Shell with jinja filter | ||
ansible.builtin.shell: | ||
cmd: echo {{ "hello" | upper }} | ||
changed_when: false | ||
|
||
- name: Shell with jinja filter (fqcn) | ||
ansible.builtin.shell: | ||
cmd: echo {{ "hello" | upper }} | ||
changed_when: false | ||
|
||
- name: Command with executable parameter | ||
ansible.builtin.shell: | ||
cmd: clear | ||
args: | ||
executable: /bin/bash | ||
changed_when: false |
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,60 @@ | ||
--- | ||
- name: Fixture | ||
hosts: localhost | ||
tasks: | ||
- name: Shell with pipe | ||
ansible.builtin.shell: | ||
cmd: echo hello | true # noqa: risky-shell-pipe | ||
changed_when: false | ||
|
||
- name: Shell with redirect | ||
ansible.builtin.shell: | ||
cmd: echo hello > /tmp/hello | ||
changed_when: false | ||
|
||
- name: Chain two shell commands | ||
ansible.builtin.shell: | ||
cmd: echo hello && echo goodbye | ||
changed_when: false | ||
|
||
- name: Run commands in succession | ||
ansible.builtin.shell: | ||
cmd: echo hello ; echo goodbye | ||
changed_when: false | ||
|
||
- name: Use variables | ||
ansible.builtin.shell: | ||
cmd: echo $HOME $USER | ||
changed_when: false | ||
|
||
- name: Use * for globbing | ||
ansible.builtin.shell: | ||
cmd: ls foo* | ||
changed_when: false | ||
|
||
- name: Use ? for globbing | ||
ansible.builtin.shell: | ||
cmd: ls foo? | ||
changed_when: false | ||
|
||
- name: Use [] for globbing | ||
ansible.builtin.shell: | ||
cmd: ls foo[1,2,3] | ||
changed_when: false | ||
|
||
- name: Use shell generator | ||
ansible.builtin.shell: | ||
cmd: ls foo{.txt,.xml} | ||
changed_when: false | ||
|
||
- name: Use backticks | ||
ansible.builtin.shell: | ||
cmd: ls `ls foo*` | ||
changed_when: false | ||
|
||
- name: Use shell with cmd | ||
ansible.builtin.shell: | ||
cmd: | | ||
set -x | ||
ls foo? | ||
changed_when: false |
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