-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.yaml
185 lines (183 loc) · 5.08 KB
/
Taskfile.yaml
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
### The hosts block
- hosts: "{{ playbook_targets | default('localhost') }}"
gather_facts: true
become: true
### The vars block
vars:
ANSIBLE_STDOUT_CALLBACK: community.general.yaml
var1: "This is value1"
var2: value2
var3: value3
var4: |-
This is a multi-line value
of type string
var5:
- listvalue1
- listvalue2
- listvalue3
- listvalue4
var6:
some_key:
some_child_key: "do it"
var7: $(echo some_value)
var8: 8000
dbhosts:
- dbhost1
- dbhost2
- dbhost3
webhosts:
- webhost1
- webhost2
- webhost3
### Global Options Block
globals:
options:
my_global_option:
help: "This is my global option"
short: -g
long: --global
var: some_global_variable
### The commands block
commands:
run|doit:
options:
foo:
help: "This is some foo option"
short: -f
long: --foo
type: choice
var: some_foo_variable
required: True
not_required_if:
- some_bar_variable
options:
- foo1
- foo2
bar:
help: "This is some bar option"
short: -b
long: --bar
type: str
var: some_bar_variable
required: False
required_if:
- hello
- some_baz_variable
baz:
help: "This is some baz option"
short: -z
long: --baz
type: str
var: some_baz_variable
required: False
mutually_exclusive_with:
- some_bar_variable
- some_foo_variable
envvar:
help: "The value for this argument can be derived from an Environmental Variable"
short: -E
long: --env-var
type: str
var: env_var
env_var: SOME_ENVIRONMENT_VARIABLE
env_var_show: True
num:
help: "This is a numeric argument"
short: -n
long: --number
var: some_num_variable
type: int
required: False
targets:
help: "Playbook targets"
short: -t
long: --targets
type: str
var: playbook_targets
required: True
multiple:
help: |-
This option can be specified multiple times
short: -m
long: --multiple
type: str
var: multiple_arg
allow_multiple: True
some_switch:
help: |-
This is some boolean option, behaves like Click's switches,
holds the value of True if specified
see: https://github.com/pallets/click
short: -s
long: --some-switch
is_flag: true
var: some_switch
required: True
say_hello:
help: "Invoke the 'hello' embedded shell function"
short: -hello
long: --say-hello
type: str
var: hello
is_flag: True
say_goodbye:
help: "Invoke the 'goodbye' embedded shell function"
short: -goodbye
long: --say-goodbye
type: str
var: goodbye
is_flag: True
hidden_option:
help: "This is a hidden option"
short: -O
long: --hidden-option
is_hidden: True
type: str
var: hidden
is_flag: True
verbose:
help: |-
This is a sample paramter that supports counting, as with:
-v, -vv, -vvv, which would evaluate to 1, 2, and 3, respectively
short: -v
allow_counting: True
var: verbosity
### The help message
help:
message: |
Invoke the ${__command__} command
epilog: |
This line will be displayed at the end of the help text message
examples:
- example1: |
tasks $__command__
- example2: |
Usage example 2
### Embedded shell functions
functions:
hello:
shell: bash
help: Say hello
source: |-
echo Hello! The value for var1 is $var1
goodbye:
shell: bash
help: Say goodbye
source: |-
echo The value for var1 is $var1. Goodbye!
### Inventory expression
inventory_expression: |
[local]
localhost ansible_connection=local
[web_hosts]
$(echo -e "${webhosts}" | jq -r '.[]')
[db_hosts]
$(echo -e "${dbhosts}" | jq -r '.[]')
[myhosts:children]
web_hosts
db_hosts
tasks:
- name: Show Variables
debug:
msg: |-
{{ hostvars[inventory_hostname] | to_nice_json }}