From: Felix Dörre Date: Sun, 16 Jul 2017 17:06:16 +0000 (+0200) Subject: upd: cleanup inclusion of config and document config elements X-Git-Url: https://code.wpia.club/?p=infra.git;a=commitdiff_plain;h=fadef126716317722defc33a923de50fa7466303 upd: cleanup inclusion of config and document config elements Change-Id: I8ee625b6e8ad85ae68c75875d07f9bd829de442a --- diff --git a/manager/config b/manager/config new file mode 100755 index 0000000..6625d0d --- /dev/null +++ b/manager/config @@ -0,0 +1,66 @@ +### Documentation for configuration options + +## Variables + +# (required) Base domain for infra system installation. +#to= + +# (required) Hostname or IP address of the infra system. +#domain= + +# Additional packages that should be installed. +devPkgs="" + +# How to connect to the signer backend. +# +# Either the name for the serial device or "self" to indicate that a signer container should be set up. +signerLocation=self + +## Functions + +# Run a command in the infra system, accepting additional ssh-options. +function ssh_target { + ssh -i vm-key "$to" "$@" +} + +# Install nre-files to the target system. +# +# * Extract all "signer-server" to modules/cassiopeia_signer/files in the target system. +# * Extract all "signer-client" to modules/cassiopeia_client/files in the target system. +# * Extract all "gigi" to modules/ner/files in the target system. +function install_nre { + ./installNRE "$targetHost" +} + +# Configure variables for puppet. +# +# The default implementation prompts the user for all required variables. +function configure { + ssh_target -t 'bash conf-puppet --force' + ssh_target 'sed -i "s%\$signerLocation = '".*'"'%\$signerLocation = '"'$signerLocation'"'%" environments/production/manifests/ip.pp' +} + +# Reset a vm to its base snapshot. +# +# The default implementation asks the user to do so. +function do_reset_vm { + read -rp "Please reset your VM and confirm by pressing enter." _ +} + +# Execute the gigi bootstrapping process. By default the process interacts with the user. +# +# This function can be overridden to execute "execute-bootstrap-user-auto" in order to automate this bootstrapping process. +# Make sure to provide "bootstrapper_details" to provide the necessary answers. +# To fully automate bootstrapping, you need to provide a way to extract the activation link (see "read_activation_link"). +function execute-bootstrap-user { + ssh_target -t 'bash bootstrap-user' +} + +# Obtain the activation link in the variable "$link". +# +# This is required for activating the first bootstrappers account. +# This is only required for automated bootstrap user. +function read_activation_link { + read -rp "Link: " link + printf '%s\n' "$link" +} diff --git a/manager/fetch b/manager/fetch index 184e488..7e7f1e1 100755 --- a/manager/fetch +++ b/manager/fetch @@ -1,10 +1,8 @@ #!/bin/bash -function ssh_target { - ssh -i vm-key "$to" "$@" -} -target=$1 -target=${target%/} -source "$target/config" +targetHost=$1 +targetHost=${targetHost%/} +source config +source "$targetHost/config" echo "To: $to" echo "Agent: $SSH_AGENT_PID" @@ -18,7 +16,7 @@ echo "Action: $command" if [[ $command == "push" ]]; then git push -f "$to:" "HEAD:refs/remotes/manager/master" else - git fetch "$to:" "+HEAD:refs/remotes/$target/master" + git fetch "$to:" "+HEAD:refs/remotes/$targetHost/master" fi if [[ $oldpid == "" ]]; then eval $(ssh-agent -k) diff --git a/manager/installNRE b/manager/installNRE index 2116eaf..2e28c60 100755 --- a/manager/installNRE +++ b/manager/installNRE @@ -1,10 +1,8 @@ #!/bin/bash -signerLocation=self -function ssh_target { - ssh -i vm-key "$to" "$@" -} - -source "$1/config" +targetHost=$1 +targetHost=${targetHost%/} +source config +source "$targetHost/config" function extract { pattern=$1 diff --git a/manager/setup b/manager/setup index 9481c85..0fb4061 100755 --- a/manager/setup +++ b/manager/setup @@ -1,30 +1,7 @@ #!/bin/bash -signerLocation=self -devPkgs="" -targetHost="$1" - -function ssh_target { - ssh -i vm-key "$to" "$@" -} - -function install_nre { - ./installNRE "$targetHost" -} -function read_activation_link { - read -rp "Link: " link - printf '%s\n' "$link" -} -function configure { - ssh_target -t 'bash conf-puppet --force' - ssh_target 'sed -i "s%\$signerLocation = '".*'"'%\$signerLocation = '"'$signerLocation'"'%" environments/production/manifests/ip.pp' -} -function do_reset_vm { - read -rp "Please reset your VM and confirm by pressing enter." _ -} -function execute-bootstrap-user { - ssh_target -t 'bash bootstrap-user' -} - +targetHost=$1 +targetHost=${targetHost%/} +source config source "$targetHost/config" eval $(ssh-agent)