X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=deploy%2Fsite%2Fvm%2Fvm.sh;h=3f3b3fbb2677122d53d7dbd2f3865e35457e3d3d;hb=50b3ce56a980a97e69762fc2b4341f6fffe4df73;hp=de1fdf8468298992fb07570e5c5822d034b37ee8;hpb=860d3ddea953c3f77df35762afc1a282157c846b;p=icn.git diff --git a/deploy/site/vm/vm.sh b/deploy/site/vm/vm.sh index de1fdf8..3f3b3fb 100755 --- a/deploy/site/vm/vm.sh +++ b/deploy/site/vm/vm.sh @@ -10,16 +10,21 @@ source $SCRIPTDIR/../common.sh BUILDDIR=${SCRIPTDIR/deploy/build} mkdir -p ${BUILDDIR} +SITE_REPO=${SITE_REPO:-"https://gerrit.akraino.org/r/icn"} +SITE_BRANCH=${SITE_BRANCH:-"master"} +SITE_PATH=${SITE_PATH:-"deploy/site/vm"} + FLUX_SOPS_KEY_NAME=${FLUX_SOPS_KEY_NAME:-"icn-site-vm"} +FLUX_SOPS_PRIVATE_KEY="${SCRIPTDIR}/../secrets/sops.asc" # !!!NOTE!!! THE KEYS USED BELOW ARE FOR TEST PURPOSES ONLY. DO NOT # USE THESE OUTSIDE OF THIS ICN VIRTUAL TEST ENVIRONMENT. function build_source { # First decrypt the existing site YAML, otherwise we'll be # attempting to encrypt it twice below - if [[ -f ${SCRIPTDIR}/sops.asc ]]; then - gpg --import ${SCRIPTDIR}/sops.asc - sops_decrypt_site ${SCRIPTDIR}/site.yaml + if [[ -f ${FLUX_SOPS_PRIVATE_KEY} ]]; then + gpg --import ${FLUX_SOPS_PRIVATE_KEY} + sops_decrypt ${SCRIPTDIR}/site.yaml fi # Generate user password and authorized key in site YAML @@ -34,19 +39,19 @@ function build_source { # Encrypt the site YAML create_gpg_key ${FLUX_SOPS_KEY_NAME} - sops_encrypt_site ${SCRIPTDIR}/site.yaml ${FLUX_SOPS_KEY_NAME} + sops_encrypt ${SCRIPTDIR}/site.yaml ${FLUX_SOPS_KEY_NAME} # ONLY FOR TEST ENVIRONMENT: save the private key used - export_gpg_private_key ${FLUX_SOPS_KEY_NAME} >${SCRIPTDIR}/sops.asc + export_gpg_private_key ${FLUX_SOPS_KEY_NAME} >${FLUX_SOPS_PRIVATE_KEY} } function deploy { - gpg --import ${SCRIPTDIR}/sops.asc - flux_create_site https://gerrit.akraino.org/r/icn master deploy/site/vm ${FLUX_SOPS_KEY_NAME} + gpg --import ${FLUX_SOPS_PRIVATE_KEY} + flux_create_site ${SITE_REPO} ${SITE_BRANCH} ${SITE_PATH} ${FLUX_SOPS_KEY_NAME} } function clean { - kubectl -n flux-system delete kustomization icn-master-site-vm + kubectl -n flux-system delete kustomization $(flux_site_kustomization_name ${SITE_REPO} ${SITE_BRANCH} ${SITE_PATH}) } function is_cluster_ready { @@ -65,6 +70,10 @@ function insert_control_plane_network_identity_into_ssh_config { # This enables logging into the control plane machines from this # machine without specifying the identify file on the command line + if [[ ! $(which ipcalc) ]]; then + apt-get install -y ipcalc + fi + # Create ssh config if it doesn't exist mkdir -p ${HOME}/.ssh && chmod 700 ${HOME}/.ssh touch ${HOME}/.ssh/config @@ -80,7 +89,12 @@ function insert_control_plane_network_identity_into_ssh_config { cat <>${HOME}/.ssh/config Host ${host} IdentityFile ${SCRIPTDIR}/id_rsa + StrictHostKeyChecking no + UserKnownHostsFile /dev/null EOF + # Add the identity to authorized keys on this host to enable ssh + # logins via its control plane address + cat ${SCRIPTDIR}/id_rsa.pub >> ~/.ssh/authorized_keys } function wait_for_all_ready {