blob: 6a95ce6eec02228dbdd815d15ac6427870b23739 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
__ossh_known_hosts(){
if [[ -f ~/.ansible/tmp/multi_ec2_inventory.cache ]]; then
/usr/bin/python -c 'import json,os; z = json.loads(open("%s"%os.path.expanduser("~/.ansible/tmp/multi_ec2_inventory.cache")).read()); print "\n".join(["%s.%s" % (host["ec2_tag_Name"],host["ec2_tag_environment"]) for dns, host in z["_meta"]["hostvars"].items()])'
fi
}
_ossh()
{
local cur prev known_hosts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
known_hosts="$(__ossh_known_hosts)"
COMPREPLY=( $(compgen -W "${known_hosts}" -- ${cur}))
return 0
}
complete -F _ossh ossh oscp
|