Skip to content

Commit

Permalink
Install concierge from snap
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Oct 18, 2024
1 parent 33e2ce9 commit 29410be
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 34 deletions.
8 changes: 4 additions & 4 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
55 changes: 25 additions & 30 deletions src/bootstrap/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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."
Expand All @@ -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

0 comments on commit 29410be

Please sign in to comment.