summaryrefslogtreecommitdiffstats
path: root/examples/playbooks/rule-risky-shell-pipe-pass.yml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/playbooks/rule-risky-shell-pipe-pass.yml')
-rw-r--r--examples/playbooks/rule-risky-shell-pipe-pass.yml70
1 files changed, 70 insertions, 0 deletions
diff --git a/examples/playbooks/rule-risky-shell-pipe-pass.yml b/examples/playbooks/rule-risky-shell-pipe-pass.yml
new file mode 100644
index 0000000..386e8e8
--- /dev/null
+++ b/examples/playbooks/rule-risky-shell-pipe-pass.yml
@@ -0,0 +1,70 @@
+---
+- name: Test fixture for risky-shell-pipe
+ hosts: localhost
+ become: false
+ tasks:
+ - name: Pipeline with pipefail
+ ansible.builtin.shell: set -o pipefail && false | cat
+ changed_when: false
+
+ - name: Pipeline with pipefail, multi-line
+ ansible.builtin.shell: |
+ set -o pipefail
+ false | cat
+ changed_when: false
+
+ - name: Pipeline with pipefail, complex set
+ ansible.builtin.shell: |
+ set -e -x -o pipefail
+ false | cat
+ changed_when: false
+
+ - name: Pipeline with pipefail, complex set
+ ansible.builtin.shell: |
+ set -e -x -o pipefail
+ false | cat
+ changed_when: false
+
+ - name: Pipeline with pipefail, complex set
+ ansible.builtin.shell: |
+ set -eo pipefail
+ false | cat
+ changed_when: false
+
+ - name: Pipeline with pipefail not at first line
+ ansible.builtin.shell: |
+ echo foo
+ set -eo pipefail
+ false | cat
+ changed_when: false
+
+ - name: Pipeline without pipefail, ignoring errors # noqa: risky-shell-pipe
+ ansible.builtin.shell: false | cat
+ failed_when: false
+ changed_when: false
+
+ - name: Non-pipeline without pipefail # noqa: command-instead-of-shell
+ ansible.builtin.shell: "true"
+ changed_when: false
+
+ - name: Command without pipefail
+ ansible.builtin.command: "true"
+ changed_when: false
+
+ - name: Shell with or
+ ansible.builtin.shell: false || true
+ changed_when: false
+
+ - name: Another one
+ ansible.builtin.shell: |
+ set -o pipefail
+ df | grep '/dev'
+ changed_when: false
+
+ - name: "PowerShell with pipefail should be ok, bug #3161"
+ # https://github.com/ansible/ansible-lint/issues/3161
+ ansible.builtin.shell:
+ executable: /bin/pwsh
+ cmd: |
+ $ProgressPreference = 'this | that'
+ changed_when: false