summaryrefslogtreecommitdiff
path: root/library/jexec.sh
diff options
context:
space:
mode:
Diffstat (limited to 'library/jexec.sh')
-rwxr-xr-xlibrary/jexec.sh17
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 }'