Skip to content

Commit 89297aa

Browse files
committed
test: set shell to /bin/bash in order to use pipefail
Some of our tests now run on an ubuntu control node (localhost) and use `shell` to execute commands there. Ansible requires the use of `pipefail`. The default shell on ubuntu is not bash and does not have `pipefail`. Signed-off-by: Rich Megginson <[email protected]>
1 parent 75f15f1 commit 89297aa

File tree

1 file changed

+42
-38
lines changed

1 file changed

+42
-38
lines changed

tests/tasks/get_modules_and_utils_paths.yml

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -40,55 +40,59 @@
4040
# would translate to tar -C /home/user/.ansible/collections \
4141
# ansible_collections/fedora/linux_system_roles/plugins/modules
4242
- name: Find parent directory and path of modules
43-
shell: |
44-
set -euxo pipefail
45-
for dir in {{ modules_search_path | join(" ") }}; do
46-
if [ -f "$dir/network_connections.py" ]; then
47-
readlink -f "$(dirname "$dir")"
48-
basename "$dir"
49-
exit 0
50-
fi
51-
done
52-
for dir in {{ collection_paths | join(" ") }}; do
53-
if [ ! -d "$dir" ]; then continue; fi
54-
cd "$dir"
55-
for subdir in ansible_collections/*/*/plugins/modules; do
56-
if [ -f "$subdir/network_connections.py" ]; then
57-
echo "$dir"
58-
echo "$subdir"
43+
shell:
44+
executable: /bin/bash # ensure pipefail setting
45+
cmd: |
46+
set -euxo pipefail
47+
for dir in {{ modules_search_path | join(" ") }}; do
48+
if [ -f "$dir/network_connections.py" ]; then
49+
readlink -f "$(dirname "$dir")"
50+
basename "$dir"
5951
exit 0
6052
fi
6153
done
62-
done
63-
echo network_connections.py not found
64-
exit 1
54+
for dir in {{ collection_paths | join(" ") }}; do
55+
if [ ! -d "$dir" ]; then continue; fi
56+
cd "$dir"
57+
for subdir in ansible_collections/*/*/plugins/modules; do
58+
if [ -f "$subdir/network_connections.py" ]; then
59+
echo "$dir"
60+
echo "$subdir"
61+
exit 0
62+
fi
63+
done
64+
done
65+
echo network_connections.py not found
66+
exit 1
6567
delegate_to: localhost
6668
register: modules_parent_and_dir
6769
changed_when: false
6870

6971
- name: Find parent directory and path of module_utils
70-
shell: |
71-
set -euxo pipefail
72-
for dir in {{ module_utils_search_path | join(" ") }}; do
73-
if [ -d "$dir/network_lsr" ]; then
74-
readlink -f "$(dirname "$dir")"
75-
basename "$dir"
76-
exit 0
77-
fi
78-
done
79-
for dir in {{ collection_paths | join(" ") }}; do
80-
if [ ! -d "$dir" ]; then continue; fi
81-
cd "$dir"
82-
for subdir in ansible_collections/*/*/plugins/module_utils; do
83-
if [ -d "$subdir/network_lsr" ]; then
84-
echo "$dir"
85-
echo "$subdir"
72+
shell:
73+
executable: /bin/bash # ensure pipefail setting
74+
cmd: |
75+
set -euxo pipefail
76+
for dir in {{ module_utils_search_path | join(" ") }}; do
77+
if [ -d "$dir/network_lsr" ]; then
78+
readlink -f "$(dirname "$dir")"
79+
basename "$dir"
8680
exit 0
8781
fi
8882
done
89-
done
90-
echo network_lsr not found
91-
exit 1
83+
for dir in {{ collection_paths | join(" ") }}; do
84+
if [ ! -d "$dir" ]; then continue; fi
85+
cd "$dir"
86+
for subdir in ansible_collections/*/*/plugins/module_utils; do
87+
if [ -d "$subdir/network_lsr" ]; then
88+
echo "$dir"
89+
echo "$subdir"
90+
exit 0
91+
fi
92+
done
93+
done
94+
echo network_lsr not found
95+
exit 1
9296
delegate_to: localhost
9397
register: module_utils_parent_and_dir
9498
changed_when: false

0 commit comments

Comments
 (0)