blob: e34ca5bd4f7af62a71c400243b5ad96006ba8346 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#compdef ossh oscp
_ossh_known_hosts(){
if [[ -f ~/.ansible/tmp/multi_inventory.cache ]]; then
print $(/usr/bin/python -c 'import json,os; z = json.loads(open("%s"%os.path.expanduser("~/.ansible/tmp/multi_inventory.cache")).read()); print "\n".join(["%s.%s" % (host["ec2_tag_Name"],host["ec2_tag_env"]) for dns, host in z["_meta"]["hostvars"].items()])')
fi
}
_ossh(){
local curcontext="$curcontext" state line
typeset -A opt_args
common_arguments=(
'(- *)'{-h,--help}'[show help]' \
{-v,--verbose}'[enable verbose]' \
{-d,--debug}'[debug mode]' \
{-l,--login_name}+'[login name]:login_name' \
{-c,--command}+'[command to run on remote host]:command' \
{-o,--ssh_opts}+'[SSH Options to pass to SSH]:ssh options' \
{-e,--env}+'[environtment to use]:environment:->env' \
'--list[list out hosts]' \
':OP Hosts:->oo_hosts'
)
case "$service" in
ossh)
_arguments -C -s \
"$common_arguments[@]" \
;;
oscp)
_arguments -C -s \
"$common_arguments[@]" \
{-r,--recurse}'[Recursive copy]' \
':file:_files'
;;
esac
case "$state" in
oo_hosts)
_values 'oo_hosts' $(_ossh_known_hosts)
;;
env)
_values 'environment' ops int stg prod
;;
esac
}
_ossh "$@"
|