mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Use command= when we intended to
While here sort register variables and add a comment to signal multiline testing.
This commit is contained in:
parent
12968acd5f
commit
fce04b1eba
1 changed files with 15 additions and 13 deletions
|
@ -82,7 +82,7 @@
|
||||||
file: path={{output_dir_test}}/afile.txt state=absent
|
file: path={{output_dir_test}}/afile.txt state=absent
|
||||||
|
|
||||||
- name: create afile.txt with create_afile.sh via command
|
- name: create afile.txt with create_afile.sh via command
|
||||||
shell: "{{output_dir_test | expanduser}}/create_afile.sh {{output_dir_test | expanduser}}/afile.txt creates={{output_dir_test | expanduser}}/afile.txt"
|
command: "{{output_dir_test | expanduser}}/create_afile.sh {{output_dir_test | expanduser}}/afile.txt creates={{output_dir_test | expanduser}}/afile.txt"
|
||||||
|
|
||||||
- name: verify that afile.txt is present
|
- name: verify that afile.txt is present
|
||||||
file: path={{output_dir_test}}/afile.txt state=file
|
file: path={{output_dir_test}}/afile.txt state=file
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
# removes
|
# removes
|
||||||
|
|
||||||
- name: remove afile.txt with remote_afile.sh via command
|
- name: remove afile.txt with remote_afile.sh via command
|
||||||
shell: "{{output_dir_test | expanduser}}/remove_afile.sh {{output_dir_test | expanduser}}/afile.txt removes={{output_dir_test | expanduser}}/afile.txt"
|
command: "{{output_dir_test | expanduser}}/remove_afile.sh {{output_dir_test | expanduser}}/afile.txt removes={{output_dir_test | expanduser}}/afile.txt"
|
||||||
|
|
||||||
- name: verify that afile.txt is absent
|
- name: verify that afile.txt is absent
|
||||||
file: path={{output_dir_test}}/afile.txt state=absent
|
file: path={{output_dir_test}}/afile.txt state=absent
|
||||||
|
@ -161,21 +161,23 @@
|
||||||
|
|
||||||
- name: remove afile.txt using rm
|
- name: remove afile.txt using rm
|
||||||
shell: rm {{output_dir_test | expanduser}}/afile.txt removes={{output_dir_test | expanduser}}/afile.txt
|
shell: rm {{output_dir_test | expanduser}}/afile.txt removes={{output_dir_test | expanduser}}/afile.txt
|
||||||
register: shell_result4
|
register: shell_result3
|
||||||
|
|
||||||
- name: assert that using rm under shell causes a warning
|
- name: assert that using rm under shell causes a warning
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "shell_result4.warnings"
|
- "shell_result3.warnings"
|
||||||
|
|
||||||
- name: verify that afile.txt is absent
|
- name: verify that afile.txt is absent
|
||||||
file: path={{output_dir_test}}/afile.txt state=absent
|
file: path={{output_dir_test}}/afile.txt state=absent
|
||||||
register: shell_result5
|
register: shell_result4
|
||||||
|
|
||||||
- name: assert that the file was removed by the shell
|
- name: assert that the file was removed by the shell
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "shell_result5.changed == False"
|
- "shell_result4.changed == False"
|
||||||
|
|
||||||
|
# multiline
|
||||||
|
|
||||||
- name: execute a shell command using a literal multiline block
|
- name: execute a shell command using a literal multiline block
|
||||||
args:
|
args:
|
||||||
|
@ -189,28 +191,28 @@
|
||||||
| tr -s ' ' \
|
| tr -s ' ' \
|
||||||
| cut -f1 -d ' '
|
| cut -f1 -d ' '
|
||||||
echo "this is a second line"
|
echo "this is a second line"
|
||||||
register: shell_result6
|
register: shell_result5
|
||||||
|
|
||||||
- debug: var=shell_result6
|
- debug: var=shell_result5
|
||||||
|
|
||||||
- name: assert the multiline shell command ran as expected
|
- name: assert the multiline shell command ran as expected
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "shell_result6.changed"
|
- "shell_result5.changed"
|
||||||
- "shell_result6.stdout == '5575bb6b71c9558db0b6fbbf2f19909eeb4e3b98\nthis is a second line'"
|
- "shell_result5.stdout == '5575bb6b71c9558db0b6fbbf2f19909eeb4e3b98\nthis is a second line'"
|
||||||
|
|
||||||
- name: execute a shell command using a literal multiline block with arguments in it
|
- name: execute a shell command using a literal multiline block with arguments in it
|
||||||
shell: |
|
shell: |
|
||||||
executable=/bin/bash
|
executable=/bin/bash
|
||||||
creates={{output_dir_test | expanduser}}/afile.txt
|
creates={{output_dir_test | expanduser}}/afile.txt
|
||||||
echo "test"
|
echo "test"
|
||||||
register: shell_result7
|
register: shell_result6
|
||||||
|
|
||||||
- name: assert the multiline shell command with arguments in it run as expected
|
- name: assert the multiline shell command with arguments in it run as expected
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "shell_result7.changed"
|
- "shell_result6.changed"
|
||||||
- "shell_result7.stdout == 'test'"
|
- "shell_result6.stdout == 'test'"
|
||||||
|
|
||||||
- name: remove the previously created file
|
- name: remove the previously created file
|
||||||
file: path={{output_dir_test}}/afile.txt state=absent
|
file: path={{output_dir_test}}/afile.txt state=absent
|
||||||
|
|
Loading…
Reference in a new issue