Skip to content

Commit

Permalink
Use bash for all shell invocations (#12)
Browse files Browse the repository at this point in the history
The aim is to improve compatibility across distributions.
  • Loading branch information
kysrpex authored Sep 12, 2023
1 parent 339f73c commit 1b36bd9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 29 deletions.
21 changes: 12 additions & 9 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
block:
- name: Launch rustus.
ansible.builtin.shell:
executable: /bin/bash
chdir: /root
cmd: nohup {{ rustus_path }} >/dev/null 2>&1 & echo $!
register: __launch
Expand Down Expand Up @@ -74,15 +75,17 @@
# curl is used instead of ansible.builtin.uri because the module's body is behaving
# differently from --data-binary. In fact, if the option -d is used with curl
# instead of --data-binary, curl hangs just as ansible's uri module.
ansible.builtin.shell: |
curl -v -X PATCH \
-H "Tus-Resumable: 1.0.0" \
-H "Host: 127.0.0.1:1081" \
-H "Content-Length: 7" \
-H "Content-Type: application/offset+octet-stream" \
-H "Upload-Offset: 0" \
{{ __create.location }} \
--data-binary 'Hello\n'
ansible.builtin.shell:
executable: /bin/bash
cmd: |
curl -v -X PATCH \
-H "Tus-Resumable: 1.0.0" \
-H "Host: 127.0.0.1:1081" \
-H "Content-Length: 7" \
-H "Content-Type: application/offset+octet-stream" \
-H "Upload-Offset: 0" \
{{ __create.location }} \
--data-binary 'Hello\n'
changed_when: true

- name: Verify that the file was uploaded succesfully.
Expand Down
38 changes: 22 additions & 16 deletions molecule/systemd/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@
# curl is used instead of ansible.builtin.uri because the module's body is behaving
# differently from --data-binary. In fact, if the option -d is used with curl
# instead of --data-binary, curl hangs just as ansible's uri module.
ansible.builtin.shell: |
curl -v -X PATCH \
-H "Tus-Resumable: 1.0.0" \
-H "Host: 127.0.0.1:10081" \
-H "Content-Length: 7" \
-H "Content-Type: application/offset+octet-stream" \
-H "Upload-Offset: 0" \
{{ __create.location }} \
--data-binary 'Hello\n'
ansible.builtin.shell:
executable: /bin/bash
cmd: |
curl -v -X PATCH \
-H "Tus-Resumable: 1.0.0" \
-H "Host: 127.0.0.1:10081" \
-H "Content-Length: 7" \
-H "Content-Type: application/offset+octet-stream" \
-H "Upload-Offset: 0" \
{{ __create.location }} \
--data-binary 'Hello\n'
changed_when: true

- name: Verify that the file was uploaded successfully.
Expand All @@ -64,17 +66,21 @@
that: __contents_upload.stdout == "Hello\\n"
always:
- name: Count number of files in the uploads folder.
ansible.builtin.shell: |
set -o pipefail
ls -lah {{ uploads_dir }} | wc -l
ansible.builtin.shell:
executable: /bin/bash
cmd: |
set -o pipefail
ls -lah {{ uploads_dir }} | wc -l
register: __count
changed_when: false

- name: Clear uploads folder.
ansible.builtin.shell: |
set -o pipefail
rm -rf {{ uploads_dir }}/* {{ uploads_dir }}/.*
ls -lah {{ uploads_dir }} | wc -l
ansible.builtin.shell:
executable: /bin/bash
cmd: |
set -o pipefail
rm -rf {{ uploads_dir }}/* {{ uploads_dir }}/.*
ls -lah {{ uploads_dir }} | wc -l
register: __count_clean
changed_when: __count.stdout != __count_clean.stdout

Expand Down
12 changes: 8 additions & 4 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
__rustus_install: false

- name: Determine whether a rustus binary is already installed
ansible.builtin.shell: type -p rustus || echo none
ansible.builtin.shell:
executable: /bin/bash
cmd: type -p rustus || echo none
register: __rustus_installed
changed_when: false

Expand Down Expand Up @@ -63,9 +65,11 @@
changed_when: false

- name: Read sha256sum.
ansible.builtin.shell: |
set -o pipefail
< {{ __rustus_tempfile_sha256.path }} tr -s ' ' | cut -d ' ' -f 1
ansible.builtin.shell:
executable: /bin/bash
cmd: |
set -o pipefail
< {{ __rustus_tempfile_sha256.path }} tr -s ' ' | cut -d ' ' -f 1
register: __rustus_sha256sum_desired
changed_when: false

Expand Down

0 comments on commit 1b36bd9

Please sign in to comment.