creates an adhoc script

這個提交存在於:
James Hackett 2022-12-19 20:38:52 +00:00
父節點 83a15d1c51
當前提交 b050850f31

30
ansible/bin/adhoc.sh 一般檔案
查看文件

@ -0,0 +1,30 @@
#!/bin/bash
if [ $1 = "help" ]; then
cat << EOH
-- Ad-hoc help --
This command is designed as a helper for running ad-hoc ansible commands.
It takes 2 arguments;
1. The host pattern match, and
2. The module followed by the command to run with that module.
-- Examples --
\$ bin/adhoc.sh all ping
# will run ping on 'all' hosts
\$ bin/adhoc.sh glados shell "cmd='echo hello world'"
# will run the shell module on the 'glados' host
EOH
exit 0
fi
if [ $# -eq 2 ]; then
ansible -i hosts $1 -m $2
exit 0
else
ansible -i hosts $1 -m $2 -a "${@:3}"
exit 0
fi