Ensure curl is installed during bootstrapping

This commit is contained in:
Simon Rand
2023-03-05 10:56:51 +00:00
parent 8c69990dbb
commit 9ae3886b2b
2 changed files with 13 additions and 4 deletions

View File

@@ -11,7 +11,7 @@ class Mrsk::Cli::Main < Mrsk::Cli::Base
desc "deploy", "Deploy app to servers"
def deploy
runtime = print_runtime do
say "Ensure Docker is installed...", :magenta
say "Ensure curl and Docker are installed...", :magenta
invoke "mrsk:cli:server:bootstrap"
say "Log into image registry...", :magenta
@@ -173,7 +173,7 @@ class Mrsk::Cli::Main < Mrsk::Cli::Base
desc "registry", "Login and -out of the image registry"
subcommand "registry", Mrsk::Cli::Registry
desc "server", "Bootstrap servers with Docker"
desc "server", "Bootstrap servers with curl and Docker"
subcommand "server", Mrsk::Cli::Server
desc "traefik", "Manage Traefik load balancer"

View File

@@ -1,6 +1,15 @@
class Mrsk::Cli::Server < Mrsk::Cli::Base
desc "bootstrap", "Ensure Docker is installed on servers"
desc "bootstrap", "Ensure curl and Docker are installed on servers"
def bootstrap
on(MRSK.hosts + MRSK.accessory_hosts) { execute "which docker || (apt-get update -y && apt-get install docker.io -y)" }
on(MRSK.hosts + MRSK.accessory_hosts) do
dependencies_to_install = [].tap do |dependencies|
dependencies << "curl" unless execute "which curl", raise_on_non_zero_exit: false
dependencies << "docker.io" unless execute "which docker", raise_on_non_zero_exit: false
end
if dependencies_to_install.any?
execute "apt-get update -y && apt-get install #{dependencies_to_install.join(' ')} -y)"
end
end
end
end