summaryrefslogtreecommitdiff
path: root/library/jexec.sh
blob: 2c4e19d4a2af94ce0d3c71e9c97fad2b940102fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 }'