-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.yaml
84 lines (76 loc) · 2.62 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
version: '3'
env:
COREUTILS_VERSION: '9.4'
BASH_VERSION: '5'
OPENSSH_VERSION: '9.7'
ANSIBLE_VERSION: '2.16'
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
install:
desc: prepare SingleUser 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: |
set -a
HUB_PERSISTENT_VOLUME_PATH="{{.HUB_PERSISTENT_VOLUME_PATH}}"
JUPYTERHUB_FQDN="{{.JUPYTERHUB_FQDN}}"
FILESERVER_EXPORT_PATH="{{.FILESERVER_EXPORT_PATH}}"
ANSIBLE_ROLES_PATH="{{.ANSIBLE_ROLES_PATH}}"
ANSIBLE_HOST_KEY_CHECKING=false
ANSIBLE_DEBUG=1
set +a
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
pkgx +ansible.com^{{.ANSIBLE_VERSION}} \
ansible-playbook \
--inventory '{{.ANSIBLE_INVENTORY_SCRIPT_PATH}}' \
-vvv \
'{{.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}}'