-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path_ansible-playbook
63 lines (56 loc) · 3.42 KB
/
_ansible-playbook
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
50
51
52
53
54
55
56
57
58
59
60
61
62
#compdef ansible-playbook
#
# Description
# -----------
# Completion script for ansible-playbook command
# Ansible v1.8.2 (http://www.ansible.com)
#
# Author
# ------
# Jonathan Thompson
# https://github.com/jdottdot
#
local context state state_descr line
typeset -A opt_args
_arguments -C \
'(- *)'{-h,--help}'[show this help message and exit]' \
'(- *)--version[show program'"'"'s version number and exit]' \
'(--ask-pass -k)'{-k,--ask-pass}'[ask for SSH password]' \
'(--ask-su-pass)--ask-su-pass[ask for su password]' \
'(--ask-sudo-pass -K)'{-K,--ask-sudo-pass}'[ask for sudo password]' \
'(--ask-vault-pass)--ask-vault-pass[ask for vault password]' \
'(--check -C)'{-C,--check}"[don't make any changes; instead, try to predict some of the changes that may occur]" \
'(--connection -c)'{-c\ CONNECTION,--connection=CONNECTION}'[connection type to use (default=smart)]' \
'(--diff -D)'{-D,--diff}'[when changing (small) files and templates, show the differences in those files; works great with --check]' \
'(--extra -e-vars)'{-e\ EXTRA_VARS,--extra-vars=EXTRA_VARS}'[set additional variables as key=value or YAML/JSON]' \
'(--flush-cache)--flush-cache[clear the fact cache]' \
'(--force-handlers)--force-handlers[run handlers even if a task fails]' \
'(--forks -f)'{-f\ FORKS,--forks=FORKS}'[specify number of parallel processes to use (default=5)]' \
'(--inventory -i-file)'{-i=,--inventory-file=}'[specify inventory host file (default=/etc/ansible/hosts)]: :_files' \
'(--limit -l)'{-l\ SUBSET,--limit=SUBSET}'[further limit selected hosts to an additional pattern]' \
'(--list-hosts)--list-hosts[outputs a list of matching hosts; does not execute anything else]' \
'(--list-tasks)--list-tasks[list all tasks that would be executed]' \
'(--module-path -M)'{-M\ MODULE_PATH,--module-path=MODULE_PATH}'[specify path(s) to module library (default=None)]' \
'(--private-key)--private-key=PRIVATE_KEY_FILE[use this file to authenticate the connection]' \
'(--skip-tags)--skip-tags=SKIP_TAGS[only run plays and tasks whose tags do not match these values]' \
'(--start-at-task)--start-at-task=[start the playbook at the task matching this name]: :->START_AT_TASK' \
'(--step)--step[one-step-at-a-time: confirm each task before running]' \
'(--su -S)'{-S,--su}'[run operations with su]' \
'(--su-user -R)'{-R\ SU_USER,--su-user=SU_USER}'[run operations with su as this user (default=root)]' \
'(--sudo -U-user)'{-U\ SUDO_USER,--sudo-user=SUDO_USER}'[desired sudo user (default=root)]' \
'(--sudo -s)'{-s,--sudo}'[run operations with sudo (nopasswd)]' \
'(--syntax-check)--syntax-check[perform a syntax check on the playbook, but do not execute it]' \
'(--tags -t)'{-t\ TAGS,--tags=TAGS}'[only run plays and tasks tagged with these values]' \
'(--timeout -T)'{-T\ TIMEOUT,--timeout=TIMEOUT}'[override the SSH timeout in seconds (default=10)]' \
'(--user -u)'{-u\ REMOTE_USER,--user=REMOTE_USER}'[connect as this user (default=logged_in_user)]' \
'(--vault-password-file=VAULT_PASSWORD_FILE)--vault-password-file=VAULT_PASSWORD_FILE[vault password file]' \
'(--verbose -v)'{-v,--verbose}'[verbose mode (-vvv for more, -vvvv to enable connection debugging)]' \
'*:files:_files' \
case $state in
START_AT_TASK)
tasklist=( ${(f)"$(
ansible-playbook --list-tasks ${~line} 2> /dev/null | grep 'TAGS: \[' | sed 's/^[ ]*//;s/[ ]*$//' | sed -r 's/[\t]+TAGS: \[.*//'
)"} )
compadd -V unsorted -a tasklist
;;
esac