예제 #1
0
        /// <summary>
        /// Updates Vault on a specific node.
        /// </summary>
        /// <param name="node">The target node.</param>
        /// <param name="stepDelay">The step delay.</param>
        private void UpdateVault(SshProxy <NodeDefinition> node, TimeSpan stepDelay)
        {
            if (node.GetVaultVersion() >= (SemanticVersion)version)
            {
                return;     // Already updated
            }

            node.Status = $"update: vault";

            var bundle = new CommandBundle("./install.sh", version);

            bundle.AddFile("install.sh",
                           $@"#!/bin/bash

set -euo pipefail

curl {Program.CurlOptions} https://releases.hashicorp.com/vault/$1/vault_$1_linux_amd64.zip -o /tmp/vault.zip 1>&2
unzip -o /tmp/vault.zip -d /tmp
rm /tmp/vault.zip

mv /tmp/vault /usr/local/bin/vault
chmod 700 /usr/local/bin/vault
",
                           isExecutable: true);

            node.SudoCommand(bundle);

            if (node.Metadata.IsManager)
            {
                node.Status = $"restart: vault";
                node.SudoCommand("systemctl restart vault");

                node.Status = $"unseal: vault";
                hive.Vault.Unseal();

                node.Status = $"stabilizing ({Program.WaitSeconds}s)";
                Thread.Sleep(TimeSpan.FromSeconds(Program.WaitSeconds));
            }
        }