-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTaskfile.yaml
177 lines (166 loc) · 4.89 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
---
version: 3
interval: 1000ms
tasks:
default:
desc: Run the default task (export)
deps:
- task: pre-checks
- task: pre-commit
cmds:
- task: export
force:
desc: Clean up and then re-export all scripts
summary: |
Force a run (by first cleaning up) all the scripts to be exported, and then
running the export of the configurations.
deps:
- task: pre-checks
cmds:
- task: clean
- task: export
pre-checks:
desc: Check the environment before exporting
internal: true
silent: true
run: once
cmds:
- cmd: |-
test -x "$(which pre-commit 2>/dev/null)" \
|| (echo "Cannot find 'pre-commit'. Please install before trying again."; exit 1)
- cmd: |-
test -x "$(which jq 2>/dev/null)" \
|| (echo "Cannot find 'jq'. Please install before trying again."; exit 1)
- cmd: |-
test -x "$(which yq 2>/dev/null)" \
|| (echo "Cannot find 'yq'. Please install before trying again."; exit 1)
- cmd: |-
test -x "$(which parallel 2>/dev/null)" \
|| (echo "Cannot find 'parallel'. Please install before trying again."; exit 1)
- cmd: |-
test -x "$(which gomplate 2>/dev/null)" \
|| (echo "Cannot find 'gomplate'. Please install before trying again."; exit 1)
- cmd: |-
test -x "$(which yamllint 2>/dev/null)" \
|| (echo "Cannot find 'yamllint'. Please install before trying again."; exit 1)
status:
# Setting this file will bypass pre-checks (only use if you are sure)
- test -f .skip-pre-checks
pre-commit:
desc: Set up the pre-commit hook in this repository
internal: true
silent: true
run: once
deps:
- task: pre-checks
cmds:
- cmd: pre-commit install
generates:
- .git/hooks/pre-commit
status:
- test -f .git/hooks/pre-commit
directories:
desc: Ensure all required directories are created before running tasks
run: once
silent: true
internal: true
cmds:
- cmd: |-
mkdir -p hosts networks exports
generates:
- hosts
- networks
- exports
status:
- test -d hosts
- test -d networks
- test -d exports
lint:
desc: Check and lint files for correctness
summary: |-
For files which can be linted and checked, itterate over the files and
check them for validity and correctness, as supported, catching errors
before they're used in gomplate.
deps:
- task: pre-checks
cmds:
- task: lint-yaml
lint-yaml:
desc: Check and lint all YAML files
deps:
- task: pre-checks
internal: true
sources:
- "hosts/*.yaml"
- "networks/*.yaml"
- "examples/*.yaml"
cmds:
- cmd: |-
yamllint -c .yamllint.yaml \
{examples,hosts,networks}/*.yaml
export:
desc: Build and export the scripts for all (or selected) hosts and exports
summary: |-
Build and export all the required configuration scripts for all the hosts
needed (as set by the fuzzy search). By default, all export types will be
build and exported for all known hosts.
deps:
- task: pre-checks
- task: lint
- task: directories
sources:
- hosts/*
- networks/*
- scripts/*
- templates/exports/*.scr.t
- templates/exports/*.rsc.t
- templates/parts/*.rsc.t
cmds:
- cmd: |-
scripts/exports {{ .CLI_ARGS }} \
| parallel -kj 10 scripts/export
upload:
desc: Upload the scripts for all (or selected) hosts and export types
summary: |-
Upload all the required configuration scripts for all the hosts needed (as
set by the fuzzy search). By default, all export types will be uploaded
for all known hosts.
deps:
- task: export
- task: pre-checks
- task: directories
sources:
- exports/*
cmds:
- cmd: |-
scripts/exports {{ .CLI_ARGS }} \
| xargs -n 1 -r scripts/upload
examples:
desc: Build and export scripts based on the examples only
summary: |-
Build and export the scripts for all the hosts in the examples directory only.
deps:
- task: pre-checks
- task: lint
- task: directories
sources:
- examples/*
- templates/exports/*.scr.t
- templates/exports/*.rsc.t
- templates/parts/*.rsc.t
env:
use_examples: true
cmds:
- cmd: |-
scripts/exports {{ .CLI_ARGS }} \
| parallel -kj 10 scripts/export
clean:
desc: Clean up the temporary files from the repository
summary: |
Remove any generated configuration files and temporary files from the repository.
run: once
silent: true
cmds:
- cmd: rm -rf exports/*.rsc exports/*.scr
- cmd: rm -rf exports/.????-gomplate-config.json
- cmd: rm -rf .task