diff --git a/action.yaml b/action.yaml index 77766dd..371c4a5 100644 --- a/action.yaml +++ b/action.yaml @@ -2,12 +2,12 @@ name: "Setup Operator environment" description: "Setup a operator environment" author: "Adam Stokes" inputs: - concierge-version: + concierge-channel: description: | - Version of concierge to install - https://github.com/jnsgruk/concierge/releases + Channel of concierge to install + https://snapcraft.io/concierge required: false - default: "latest" + default: "latest/stable" provider: description: | Which Juju provider to use. Can be "lxd", "microk8s" or "microstack", diff --git a/src/bootstrap/main.sh b/src/bootstrap/main.sh index 437d1f4..4a72f0c 100755 --- a/src/bootstrap/main.sh +++ b/src/bootstrap/main.sh @@ -12,40 +12,37 @@ function _get_input() { # waitSnapdSeed: wait for snapd to be seeded. # Optional argument: timeout in seconds, defaults to 60. -function _wait_snapd_seed() ( +function wait_snapd_seed() ( + echo "::group::Waiting for snapd seed..." waitSecs="${1:-60}" - if timeout "${waitSecs}" sudo snap wait system seed.loaded; then - return 0 # Success. - fi - echo "snapd not seeded after ${waitSecs}s" - return 1 # Failed. + timeout "${waitSecs}" sudo snap wait system seed.loaded + echo "::endgroup::" ) -function prepare_snapd(){ - echo "::group::Preparing snapd..." - _wait_snapd_seed - set -x - sudo snap list - # sudo snap install snapd && sudo snap refresh snapd - # sudo snap remove --purge lxd || true - sudo snap stop lxd || true # rather than purge, stop lxd if it's running - set +x +function prepare_lxd(){ + echo "::group::Preparing lxd..." + local lxd_channel="" + _get_input lxd_channel "lxd-channel" + + local current_lxd_channel="$(snap list lxd | grep lxd | awk '{ print $4 }' || true)" + if [ "${current_lxd_channel}" != "${lxd_channel}" ]; then + # rather than purge, stop lxd if it's running + echo "Stopping lxd before refreshing to $lxd_channel with concierge..." + sudo snap stop lxd || true + fi echo "::endgroup::" } function install_concierge() { # The following will eventually just be snap install concierge - local concierge_version="" - _get_input concierge_version "concierge-version" "latest" + local concierge_channel="" + _get_input concierge_version "concierge-channel" "latest/stable" - echo "::group::Installing concierge ${concierge_version}..." - export PATH=$PATH:$HOME/go/bin - sudo snap install go --classic - go install github.com/jnsgruk/concierge@${concierge_version} + echo "::group::Installing concierge ${concierge_channel}..." + sudo snap install concierge --channel="${concierge_channel}" --classic echo "::endgroup::" } - function install_tox_if_needed() { local version="" _get_input version "tox-version" @@ -130,15 +127,11 @@ EOF echo "::group::Concierge (concierge.yaml):" cat concierge.yaml echo "::endgroup::" +} - echo "::group::Concierge (environment):" - printenv | sort | grep -i concierge - echo "::endgroup::" - +function prepare_concierge() { echo "::group::Running concierge..." - set -x - sudo -E $HOME/go/bin/concierge prepare --trace -v - set +x + sudo -E concierge prepare --trace -v echo "::endgroup::" echo "Concierge run complete." @@ -147,10 +140,12 @@ EOF } function run() { - prepare_snapd + wait_snapd_seed + prepare_lxd install_concierge install_tox_if_needed plan_concierge + prepare_concierge } run \ No newline at end of file