diff options
| author | Albert Cervin <albert@acervin.com> | 2023-03-19 17:18:01 +0100 |
|---|---|---|
| committer | Albert Cervin <albert@acervin.com> | 2023-03-19 17:18:01 +0100 |
| commit | c6f2fd36e0a8188e1f6b2a15b292e3d0a5610ac4 (patch) | |
| tree | d1c21cf0d9a2529154b33438bd91821268be5eb4 /library/jexec.sh | |
| download | datagubbe-setup-c6f2fd36e0a8188e1f6b2a15b292e3d0a5610ac4.tar.gz datagubbe-setup-c6f2fd36e0a8188e1f6b2a15b292e3d0a5610ac4.tar.xz datagubbe-setup-c6f2fd36e0a8188e1f6b2a15b292e3d0a5610ac4.zip | |
Diffstat (limited to 'library/jexec.sh')
| -rwxr-xr-x | library/jexec.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/library/jexec.sh b/library/jexec.sh new file mode 100755 index 0000000..2c4e19d --- /dev/null +++ b/library/jexec.sh @@ -0,0 +1,17 @@ +#! /usr/bin/env sh +set -e +jsonargs='<<INCLUDE_ANSIBLE_MODULE_JSON_ARGS>>' + +jailname=$(echo "$jsonargs" | jq -r '.jail' -) +cmd=$(echo "$jsonargs" | jq -r '.cmd' -) + +jexec -l -u root "$jailname" /bin/sh -c "$cmd" + +rc=$? +if [ $rc != 0 ]; then + failed="false" +else + failed="true" +fi + +echo '{ "msg": "'"$jailname"'", "rc": '"$rc"', "failed": false }' |
