Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
166 lines (163 loc) · 5.65 KB
/
Copy pathTaskfile.yml
File metadata and controls
166 lines (163 loc) · 5.65 KB
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
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: '3'
vars:
TF_DIR: "{{.ROOT_DIR}}/terraform"
CONFIG_FILE: "{{.ROOT_DIR}}/config.yaml"
STATE_DIR: "{{.ROOT_DIR}}/state"
includes:
op:
taskfile: ./op/Taskfile.yml
dir: ./op
vars:
TF_DIR: "{{.TF_DIR}}"
STATE_DIR: "{{.STATE_DIR}}"
x:
taskfile: ./extra/Taskfile.yml
optional: true
dir: ./extra
vars:
TF_DIR: "{{.TF_DIR}}"
STATE_DIR: "{{.STATE_DIR}}"
tasks:
default:
cmds:
- task --list
silent: true
download-images:
desc: Download essential images
cmds:
- ./scripts/download-images.sh
- ls -alh {{.ROOT_DIR}}/artifacts/images
artifacts-up:
desc: Build and run the artifacts server container
cmds:
- ./artifacts/run-server.sh
artifacts-curl-test:
desc: Curl artifacts server from the admin node
cmds:
- |
ARTIFACTS_SERVER_URL="$(yq e '.artifact_server_url' {{.CONFIG_FILE}})"
ssh -F {{.ROOT_DIR}}/state/ssh_config admin "sudo curl --version &>/dev/null || sudo apk add curl"
ssh -F {{.ROOT_DIR}}/state/ssh_config admin "curl ${ARTIFACTS_SERVER_URL}"
nfs-up:
desc: Build and run the NFS server (nfs-ganesha) container
cmds:
- ./nfs/run-server.sh
nfs-mount-test:
desc: Mount the NFS export from the admin node
preconditions:
- sh: test -f {{.ROOT_DIR}}/state/ssh_config
msg: "state/ssh_config not found, provision the admin node first"
- sh: ssh -F {{.ROOT_DIR}}/state/ssh_config -o ConnectTimeout=5 admin true
msg: "admin node is not reachable via SSH, make sure it is running"
cmds:
- |
MGMT_IP="$(yq e '.networks.mgmt.bridge_ip' {{.CONFIG_FILE}})"
ssh -F {{.ROOT_DIR}}/state/ssh_config admin "sudo mount.nfs4 -V &>/dev/null || sudo apk add nfs-utils"
ssh -F {{.ROOT_DIR}}/state/ssh_config admin "sudo mkdir -p /mnt/nfs-test && sudo mount -t nfs4 ${MGMT_IP}:/backup_target /mnt/nfs-test"
ssh -F {{.ROOT_DIR}}/state/ssh_config admin "sudo touch /mnt/nfs-test/.mount-test && sudo rm /mnt/nfs-test/.mount-test && sudo umount /mnt/nfs-test"
echo "NFS mount test OK"
generate-macs:
desc: Generate MAC addresses for nodes and update config file
cmds:
- ./scripts/generate-mac-addresses.sh
plan-networks:
desc: Plan networks
cmds:
- ./scripts/plan-networks.sh {{.CLI_ARGS}}
select-install-iso:
desc: "Select an ISO and update config file. Use `-- VERSION` to specify a version directly, e.g. `task select-install-iso -- v1.3.0`"
cmds:
- ./artifacts/select-install-iso.sh {{.CLI_ARGS}}
select-upgrade-iso:
desc: "Select an ISO and update config file. Use `-- VERSION` to specify a version directly, e.g. `task select-upgrade-iso -- v1.3.0`"
cmds:
- ./artifacts/select-upgrade-iso.sh {{.CLI_ARGS}}
init_tf:
desc: Initialize Terraform and download provider plugins
cmds:
- terraform -chdir={{.TF_DIR}} init
status:
- test -f {{.TF_DIR}}/.terraform.lock.hcl
init_keys:
desc: Generate shared SSH key pairs if they don't already exist
cmds:
- mkdir -p state/keys
- test -f state/keys/id_rsa || ssh-keygen -t rsa -b 4096 -f state/keys/id_rsa -N ""
status:
- test -f state/keys/id_rsa
init:
deps: [init_tf, init_keys]
config-check:
desc: Validate config.yaml for duplicate ip, mac, and vnc_port in nodes
cmds:
- python3 scripts/validate-config.py {{.CONFIG_FILE}}
check:
desc: Run all checks
deps: [config-check]
plan:
desc: Plan the terraform deployment
deps: [init]
cmds:
- terraform -chdir={{.TF_DIR}} plan
build:
desc: Build the Dev Infra
deps: [init, check]
cmds:
- terraform -chdir={{.TF_DIR}} apply --auto-approve
admin-up:
desc: Power on admin node and wait for it to be ready
cmds:
- task: build
- task: op:admin-poweron
- task: op:admin-wait
- task: op:admin-enable-egress-if-configured
up:
desc: Build base dev infra and install Harvester on nodes
deps: [admin-up]
cmds:
- task: op:nodes-install
rancher-install:
desc: Bring up the Rancher VM and wait for it to be ready
deps: [init]
cmds:
- task: op:rancher-install
rancher-reinstall:
desc: Reset the Rancher VM to initial state and provisiong a new Rancher Manager
deps: [init]
cmds:
- task: op:rancher-reinstall
nodes-install:
desc: Power on all nodes and wait for Harvester cluster to be ready
deps: [init]
cmds:
- task: op:nodes-install
nodes-reinstall:
desc: Reset node disks and re-install Harvester on all nodes again
deps: [init]
cmds:
- task: op:nodes-reinstall
clean:
desc: Tear down the Dev Infra and clean up resources
cmds:
- echo "This will clean state files, destroy VMs, and tear down the terraform infra" && ./op/confirm-op.sh {{.CLI_ARGS}}
- task: op:rancher-clean-state
- task: op:nodes-destroy
- task: op:nodes-clean-state
- terraform -chdir={{.TF_DIR}} destroy --auto-approve
# - rm -rf {{.STATE_DIR}}/keys
- rm -f {{.STATE_DIR}}/ssh_config
- rm -f kubeconfig
- task: op:harvester-clean-state
reset:
cmds:
- task clean
- task build
ssh:
desc: SSH into VMs using generated SSH config. By default, it will ssh into admin node. Use `-- NODE` to specify a node, e.g. `task ssh -- node1`
cmds:
- ssh -F {{.ROOT_DIR}}/state/ssh_config {{if .CLI_ARGS}}{{.CLI_ARGS}}{{else}}admin{{end}}
node-count:
desc: Get or set the number of nodes in config.yaml. Use `-- N` to set the count, e.g. `task node-count -- 3`
cmds:
- ./op/nodes/node-count.sh {{.CLI_ARGS}}