-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.yaml
164 lines (153 loc) · 5.65 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
version: '3'
env:
TASK_VERSION: '3.35'
COREUTILS_VERSION: '9.4'
BASH_VERSION: '5'
ANSIBLE_VERSION: '2.16'
OPENSSH_VERSION: '9.7'
JETPORCH_VERSION: '0.0.1'
PROVISIONER_REPO_PATH: '{{.TASKFILE_DIR}}'
PROJECT_REPO_PATH: '{{.ROOT_DIR}}'
ANSIBLE_INVENTORY_SCRIPT_PATH: '{{.PROVISIONER_REPO_PATH}}/inventory-ansible.pkgx'
ANSIBLE_PLAYBOOKS_PATH: '{{.PROVISIONER_REPO_PATH}}/playbooks'
ANSIBLE_ROLES_PATH: '{{.PROVISIONER_REPO_PATH}}/roles'
tasks:
default:
silent: true
cmds:
- task --list
init:
cmds:
- |
pkgx +ansible.com^{{.ANSIBLE_VERSION}} ansible-galaxy \
collection install community.general
with-clean-env:
internal: true
cmds:
- |
pkgx +gnu.org/coreutils^{{.COREUTILS_VERSION}} env \
--split-string \
--ignore-environment \
REMOTE_FQDN="{{.REMOTE_FQDN}}" \
REMOTE_USER="{{.REMOTE_USER}}" \
USER="{{.USER}}" \
HOME="{{.HOME}}" \
PATH="{{.HOME}}/.pkgx/bin:/bin:/usr/bin:/usr/local/bin" \
PROJECT_REPO_PATH='{{.PROJECT_REPO_PATH}}' \
pkgx +gnu.org/bash^{{.BASH_VERSION}} bash \
--login \
--noprofile \
--norc \
- <<'EOF'
{{- range $line := splitList "\n" .COMMAND_SCRIPT}}
{{$line -}}
{{- end}}
EOF
test:
vars:
COMMAND_SCRIPT: |
echo A
echo B
echo C
cmds:
- task: with-clean-env
vars:
COMMAND_SCRIPT: '{{.COMMAND_SCRIPT}}'
install:
desc: prepare JupyterHub instance with Ansible playbooks
vars:
ANSIBLE_TAGS: 'install'
CONSTRUCTOR_SSH_KEY_PATH:
sh: |
pkgx +taskfile.dev^{{.TASK_VERSION}} task \
--silent \
--taskfile '{{.PROJECT_REPO_PATH}}/Taskfile.yaml' \
constructor:get_ssh_key_path
COMMAND_SCRIPT: |
eval "$(pkgx +openssh.com^{{.OPENSSH_VERSION}} ssh-agent)" 2>&1 > /dev/null
pkgx +openssh.com^{{.OPENSSH_VERSION}} ssh-add -q '{{.CONSTRUCTOR_SSH_KEY_PATH}}' 2>&1 > /dev/null
#export HUB_PERSISTENT_VOLUME_PATH='{{.HUB_PERSISTENT_VOLUME_PATH}}'
#export JUPYTERHUB_FQDN='{{.JUPYTERHUB_FQDN}}'
#export NOVNC_FQDN='{{.NOVNC_FQDN}}'
#export FILESERVER_EXPORT_PATH='{{.FILESERVER_EXPORT_PATH}}'
export ANSIBLE_ROLES_PATH="{{.ANSIBLE_ROLES_PATH}}"
export ANSIBLE_HOST_KEY_CHECKING=false
pkgx +ansible.com^{{.ANSIBLE_VERSION}} ansible-playbook \
--tags '{{.ANSIBLE_TAGS}}' \
--inventory '{{.ANSIBLE_INVENTORY_SCRIPT_PATH}}' \
'{{.ANSIBLE_PLAYBOOKS_PATH}}/main.yaml'
pkgx +openssh.com^{{.OPENSSH_VERSION}} ssh-agent -k
cmds:
- task: with-clean-env
vars:
COMMAND_SCRIPT: '{{.COMMAND_SCRIPT}}'
configure:
desc: configure JupyterHub instance with Ansible playbooks
vars:
ANSIBLE_TAGS: 'configure'
CONSTRUCTOR_SSH_KEY_PATH:
sh: |
pkgx +taskfile.dev^{{.TASK_VERSION}} task \
--silent \
--taskfile '{{.PROJECT_REPO_PATH}}/Taskfile.yaml' \
constructor:get_ssh_key_path
COMMAND_SCRIPT: |
eval "$(pkgx +openssh.com^{{.OPENSSH_VERSION}} ssh-agent)" 2>&1 > /dev/null
pkgx +openssh.com^{{.OPENSSH_VERSION}} \
ssh-add -q '{{.CONSTRUCTOR_SSH_KEY_PATH}}' 2>&1 > /dev/null
export HUB_PERSISTENT_VOLUME_PATH="{{.HUB_PERSISTENT_VOLUME_PATH}}"
export JUPYTERHUB_FQDN="{{.JUPYTERHUB_FQDN}}"
export NOVNC_FQDN="{{.NOVNC_FQDN}}"
export FILESERVER_EXPORT_PATH="{{.FILESERVER_EXPORT_PATH}}"
export HOME_PREFIX="{{.HOME_PREFIX}}"
export ANSIBLE_ROLES_PATH="{{.ANSIBLE_ROLES_PATH}}"
pkgx +ansible.com^{{.ANSIBLE_VERSION}} \
ansible-playbook \
--tags '{{.ANSIBLE_TAGS}}' \
--inventory '{{.ANSIBLE_INVENTORY_SCRIPT_PATH}}' \
'{{.ANSIBLE_PLAYBOOKS_PATH}}/main.yaml'
pkgx +openssh.com^{{.OPENSSH_VERSION}} \
ssh-agent -k 2>&1 > /dev/null
cmds:
- task: with-clean-env
vars:
COMMAND_SCRIPT: '{{.COMMAND_SCRIPT}}'
#
# the image_build constructor needs this task, even empty
#
tests:
cmds:
- true
jetp_install:
#desc: prepare instance with recipes
cmds:
- |
pkgx +gnu.org/coreutils^{{.COREUTILS_VERSION}} env \
--split-string \
--ignore-environment \
REMOTE_FQDN="{{.REMOTE_FQDN}}" \
REMOTE_USER="{{.REMOTE_USER}}" \
USER="{{.USER}}" \
HOME="{{.HOME}}" \
PATH="{{.HOME}}/.pkgx/bin:/bin:/usr/bin:/usr/local/bin" \
pkgx +gnu.org/bash^{{.BASH_VERSION}} bash \
--login \
--noprofile \
--norc \
- <<'EOF'
#eval "$(pkgx --shellcode)"
source ../Taskfile.env
eval "$(pkgx +openssh.com^{{OPENSSH_VERSION}} ssh-agent)" 2>&1 > /dev/null
pkgx +openssh.com^{{OPENSSH_VERSION}} ssh-add $CONSTRUCTOR_SSH_KEY_PATH
pkgx +openssh.com^{{OPENSSH_VERSION}} ssh-add -L
export INVENTORY="./inventory.pkgx"
export PLAYBOOKS="./playbooks"
export ROLES="./roles"
pkgx +jetporch.com^{{.JETPORCH_VERSION}} jetp ssh \
--inventory "${INVENTORY}" \
--playbook "${PLAYBOOKS}/install.yml" \
--roles "${ROLES}" \
-vvv
pkgx +openssh.com^{{.OPENSSH_VERSION}} \
ssh-agent -k 2>&1 > /dev/null
EOF