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

            node.Status = $"stop: consul";
            node.SudoCommand("systemctl stop consul");

            node.Status = $"update: consul";

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

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

set -euo pipefail

curl {Program.CurlOptions} https://releases.hashicorp.com/consul/$1/consul_$1_linux_amd64.zip -o /tmp/consul.zip 1>&2
unzip -u /tmp/consul.zip -d /tmp
cp /tmp/consul /usr/local/bin
chmod 770 /usr/local/bin/consul

rm /tmp/consul.zip
rm /tmp/consul 
",
                           isExecutable: true);

            node.SudoCommand(bundle);

            node.Status = $"restart: consul";
            node.SudoCommand("systemctl restart consul");

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