creates an adhoc script
這個提交存在於:
父節點
83a15d1c51
當前提交
b050850f31
共有 1 個檔案被更改,包括 30 行新增 和 0 行删除
30
ansible/bin/adhoc.sh
一般檔案
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
|
載入中…
新增問題並參考