-
Notifications
You must be signed in to change notification settings - Fork 1
/
inventory-ansible.pkgx
executable file
·57 lines (49 loc) · 1.63 KB
/
inventory-ansible.pkgx
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
#!/usr/bin/env -S pkgx --silent +gnu.org/bash^5 bash
function get_ssh_key_path {
if [[ -z ${CONSTRUCTOR_SSH_KEY_PATH} || ! -v CONSTRUCTOR_SSH_KEY_PATH ]]; then
printf -v CONSTRUCTOR_SSH_KEY_PATH \
'%s' \
"$(pkgx task --silent --taskfile ${PROJECT_REPO_PATH}/Taskfile.yaml constructor:get_ssh_key_path)"
fi
}
function get_remote_fqdn {
if [[ -z ${REMOTE_FQDN} || ! -v REMOTE_FQDN ]]; then
printf -v REMOTE_FQDN \
'%s' \
"$(pkgx task --silent --taskfile ${PROJECT_REPO_PATH}/Taskfile.yaml constructor:get_remote_fqdn)"
fi
}
function get_remote_user {
if [[ -z ${REMOTE_USER} || ! -v REMOTE_USER ]]; then
printf -v REMOTE_USER \
'%s' \
"$(pkgx task --silent --taskfile ${PROJECT_REPO_PATH}/Taskfile.yaml constructor:get_remote_user)"
fi
}
function main {
local -r temp_dir_path="${PROJECT_REPO_PATH}/temp"
local -r inventory_file_name='inventory.json'
local -r inventory_file_path="${temp_dir_path}/${inventory_file_name}"
mkdir -p "${temp_dir_path}"
get_remote_fqdn
get_remote_user
#get_ssh_key_path
cat <<EOF > "${inventory_file_path}"
{
"targets": {
"hosts": ["${REMOTE_FQDN:-UNSET}"],
"vars": {
"ansible_host": "${REMOTE_FQDN:-UNSET}",
"ansible_user": "${REMOTE_USER:-UNSET}",
"hub_persistent_volume_path": "${HUB_PERSISTENT_VOLUME_PATH:-UNSET}",
"fileserver_export_path": "${FILESERVER_EXPORT_PATH:-UNSET}",
"jupyterhub_fqdn": "${JUPYTERHUB_FQDN:-UNSET}",
"novnc_fqdn": "${NOVNC_FQDN:-UNSET}",
"home_prefix": "${HOME_PREFIX:-UNSET}"
}
}
}
EOF
cat "${inventory_file_path}"
}
main