From 4830f0706ac7e75589549fa82b2ebc8f258f6b90 Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Thu, 23 May 2019 16:06:50 +0200 Subject: [PATCH 01/13] upgraded to ubuntu 18.10, added k3s --- install-k3s.sh | 6 ++++++ packer.json | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100755 install-k3s.sh diff --git a/install-k3s.sh b/install-k3s.sh new file mode 100755 index 0000000..7dcbafb --- /dev/null +++ b/install-k3s.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -e -o pipefail + +curl -sfL https://get.k3s.io | sh - +systemctl disable k3s diff --git a/packer.json b/packer.json index f6df7bf..800fbff 100644 --- a/packer.json +++ b/packer.json @@ -6,10 +6,11 @@ { "type": "googlecompute", "project_id": "{{user `project_id`}}", - "source_image_family": "ubuntu-1710", - "zone": "europe-west1-b", + "source_image_family": "ubuntu-1804-lts", + "zone": "europe-west4-c", "ssh_username" : "root", - "image_name": "docker-17", + "image_name": "ubuntu-1804-lts-docker", + "image_family": "ubuntu-1804", "image_labels": { "track": "docker", "created": "{{ timestamp }}" @@ -25,7 +26,10 @@ { "type": "shell", "script": "bootstrap.sh" + }, + { + "type": "shell", + "script": "install-k3s.sh" } ] - } From f12ed7b8cc53f1ff6c6db376e80d50d1d9a6d435 Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Thu, 26 Sep 2019 12:41:46 +0200 Subject: [PATCH 02/13] add k3s --- install-k3s.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-k3s.sh b/install-k3s.sh index 7dcbafb..836e114 100755 --- a/install-k3s.sh +++ b/install-k3s.sh @@ -2,5 +2,5 @@ set -e -o pipefail +apt install -y jq curl -sfL https://get.k3s.io | sh - -systemctl disable k3s From e04110f9bbb759acb712895528edc39f12ac9fac Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Thu, 26 Sep 2019 13:33:27 +0200 Subject: [PATCH 03/13] add permission --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index dc17830..52ce2bf 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,13 @@ endif build: check-variables packer build -var 'project_id=${PROJECT}' packer.json + gcloud compute images add-iam-policy-binding ubuntu-1804-lts-docker \ + --role roles/compute.imageUser \ + --member serviceAccount:instruqt-track@instruqt-prod.iam.gserviceaccount.com force-build: check-variables packer build -force -var 'project_id=${PROJECT}' packer.json + gcloud compute images add-iam-policy-binding ubuntu-1804-lts-docker \ + --role roles/compute.imageUser \ + --member serviceAccount:instruqt-track@instruqt-prod.iam.gserviceaccount.com + From 90e9ce72ea4d1c3cb312bc09f937e87166e3b678 Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Thu, 26 Sep 2019 13:49:32 +0200 Subject: [PATCH 04/13] add python3 --- bootstrap.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bootstrap.sh b/bootstrap.sh index b233279..dfed12d 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -13,6 +13,8 @@ apt-get -y install \ sudo \ vim \ nano \ + python3 \ + python3-pip \ software-properties-common # Install Docker From dd2f8aee9586fb95bb6be2f597d10bc0bf45bcf8 Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Thu, 26 Sep 2019 15:08:24 +0200 Subject: [PATCH 05/13] initialize with cloud-init to ensure up to date apt source list --- bootstrap.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index dfed12d..37fda00 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -4,7 +4,11 @@ set -e export DEBIAN_FRONTEND=noninteractive -apt-get update && apt-get -y upgrade + +/usr/bin/cloud-init -d init +/usr/bin/cloud-init -d modules +apt-get update +apt-get -y upgrade apt-get -y install \ git curl wget \ apt-transport-https \ From 5df0b3f6911f401d1538a6b13681607dcec3296d Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Sat, 28 Sep 2019 13:48:19 +0200 Subject: [PATCH 06/13] add AWS and GCP clis --- bootstrap.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bootstrap.sh b/bootstrap.sh index 37fda00..a53bcec 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -34,6 +34,8 @@ apt-get update && apt-get install -y docker-ce curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose +# install cloud libraries +pip3 install awscli google-cloud # Improve the startup sequence cp /tmp/resources/google-startup-scripts.service /etc/systemd/system/multi-user.target.wants/google-startup-scripts.service From f8ec8d13f423344cb2f82b1fff99ccaefe4c156a Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Sat, 28 Sep 2019 13:50:36 +0200 Subject: [PATCH 07/13] added documentation --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b7a84bf..088a4d3 100644 --- a/README.md +++ b/README.md @@ -1 +1,4 @@ # Packer recipe for Docker image + +Includes AWS and Google Cloud Platform CLIs and k3s. + From 8ebe2dd46d73f98efab43d3d92cbb74fae95909f Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Sat, 28 Sep 2019 14:01:28 +0200 Subject: [PATCH 08/13] refactored --- bootstrap.sh | 8 ++++++-- install-k3s.sh | 6 ------ packer.json | 4 ---- 3 files changed, 6 insertions(+), 12 deletions(-) delete mode 100755 install-k3s.sh diff --git a/bootstrap.sh b/bootstrap.sh index a53bcec..3bbe503 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -19,7 +19,8 @@ apt-get -y install \ nano \ python3 \ python3-pip \ - software-properties-common + software-properties-common \ + jq # Install Docker curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add - @@ -35,7 +36,10 @@ curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compos chmod +x /usr/local/bin/docker-compose # install cloud libraries -pip3 install awscli google-cloud +pip3 install awscli google-cloud 'docker[tls]' + +# install k3s +curl -sfL https://get.k3s.io | sh - # Improve the startup sequence cp /tmp/resources/google-startup-scripts.service /etc/systemd/system/multi-user.target.wants/google-startup-scripts.service diff --git a/install-k3s.sh b/install-k3s.sh deleted file mode 100755 index 836e114..0000000 --- a/install-k3s.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -set -e -o pipefail - -apt install -y jq -curl -sfL https://get.k3s.io | sh - diff --git a/packer.json b/packer.json index 800fbff..17f4ff8 100644 --- a/packer.json +++ b/packer.json @@ -26,10 +26,6 @@ { "type": "shell", "script": "bootstrap.sh" - }, - { - "type": "shell", - "script": "install-k3s.sh" } ] } From a5f38532d1ec1f48888caa2761241587ff534f75 Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Mon, 30 Sep 2019 07:47:10 +0200 Subject: [PATCH 09/13] add workaround for missing instruqt variables --- bootstrap.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bootstrap.sh b/bootstrap.sh index 3bbe503..c03f564 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -22,6 +22,16 @@ apt-get -y install \ software-properties-common \ jq +# workaround for missing Instruqt env. variables in check scripts +( +cat < /usr/local/bin/python3 +chmod ugo+x /usr/local/bin/python3 + # Install Docker curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add - add-apt-repository \ From 30ca48d547448a413371eea54e5bc619d8934086 Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Mon, 30 Sep 2019 09:52:11 +0200 Subject: [PATCH 10/13] add gcloud init stuff --- bootstrap.sh | 2 +- .../google-startup-scripts.service | 0 .../instruqt-configure-aws.service | 13 +++++++ .../instruqt-configure-gcloud.service | 13 +++++++ .../usr/local/bin/instruqt-configure-aws | 32 +++++++++++++++++ .../usr/local/bin/instruqt-configure-gcloud | 34 +++++++++++++++++++ 6 files changed, 93 insertions(+), 1 deletion(-) rename resources/{ => etc/systemd/system/multi-user.target.wants}/google-startup-scripts.service (100%) create mode 100644 resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-aws.service create mode 100644 resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-gcloud.service create mode 100755 resources/usr/local/bin/instruqt-configure-aws create mode 100755 resources/usr/local/bin/instruqt-configure-gcloud diff --git a/bootstrap.sh b/bootstrap.sh index c03f564..abc1170 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -52,5 +52,5 @@ pip3 install awscli google-cloud 'docker[tls]' curl -sfL https://get.k3s.io | sh - # Improve the startup sequence -cp /tmp/resources/google-startup-scripts.service /etc/systemd/system/multi-user.target.wants/google-startup-scripts.service +cp -rp /tmp/resources/ / systemctl daemon-reload diff --git a/resources/google-startup-scripts.service b/resources/etc/systemd/system/multi-user.target.wants/google-startup-scripts.service similarity index 100% rename from resources/google-startup-scripts.service rename to resources/etc/systemd/system/multi-user.target.wants/google-startup-scripts.service diff --git a/resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-aws.service b/resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-aws.service new file mode 100644 index 0000000..ba1909b --- /dev/null +++ b/resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-aws.service @@ -0,0 +1,13 @@ +[Unit] +Description=Instruqt AWS credentials configuration +After=local-fs.target network-online.target network.target rsyslog.service +After=google-instance-setup.service google-network-setup.service +Wants=local-fs.target network-online.target network.target + +[Service] +ExecStart=/usr/local/bin/instruqt-configure-aws +Type=oneshot +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-gcloud.service b/resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-gcloud.service new file mode 100644 index 0000000..88c8e39 --- /dev/null +++ b/resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-gcloud.service @@ -0,0 +1,13 @@ +[Unit] +Description=Instruqt GCloud credentials configuration +After=local-fs.target network-online.target network.target rsyslog.service +After=google-instance-setup.service google-network-setup.service +Wants=local-fs.target network-online.target network.target + +[Service] +ExecStart=/usr/local/bin/instruqt-configure-gcloud +Type=oneshot +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/resources/usr/local/bin/instruqt-configure-aws b/resources/usr/local/bin/instruqt-configure-aws new file mode 100755 index 0000000..2dba0bd --- /dev/null +++ b/resources/usr/local/bin/instruqt-configure-aws @@ -0,0 +1,32 @@ +#!/bin/bash + +# Available env vars: +# INSTRUQT_AWS_ACCOUNTS +# INSTRUQT_AWS_ACCOUNT_%s_ACCOUNT_NAME +# INSTRUQT_AWS_ACCOUNT_%s_ACCOUNT_ID +# INSTRUQT_AWS_ACCOUNT_%s_USERNAME +# INSTRUQT_AWS_ACCOUNT_%s_PASSWORD +# INSTRUQT_AWS_ACCOUNT_%s_AWS_ACCESS_KEY_ID +# INSTRUQT_AWS_ACCOUNT_%s_AWS_SECRET_ACCESS_KEY + +aws_init() { + if [[ -n ${INSTRUQT_AWS_ACCOUNTS} ]]; then + PROJECTS=("${INSTRUQT_AWS_ACCOUNTS//,/ }") + + # load all credentials into aws configure + for PROJECT in ${PROJECTS[@]}; do + aws configure --profile $PROJECT set region eu-west-1 + [[ $PROJECT == ${PROJECTS[0]} ]] && aws configure --profile default set region eu-west-1 + VAR="INSTRUQT_AWS_ACCOUNT_${PROJECT}_AWS_ACCESS_KEY_ID" + aws configure --profile $PROJECT set aws_access_key_id "${!VAR}" + [[ $PROJECT == ${PROJECTS[0]} ]] && aws configure --profile default set aws_access_key_id "${!VAR}" + VAR="INSTRUQT_AWS_ACCOUNT_${PROJECT}_AWS_SECRET_ACCESS_KEY" + aws configure --profile $PROJECT set aws_secret_access_key "${!VAR}" + [[ $PROJECT == ${PROJECTS[0]} ]] && aws configure --profile default set aws_secret_access_key "${!VAR}" + VAR="INSTRUQT_AWS_ACCOUNT_${PROJECT}_USERNAME" + USERNAME="${!VAR}" + done + fi +} + +aws_init diff --git a/resources/usr/local/bin/instruqt-configure-gcloud b/resources/usr/local/bin/instruqt-configure-gcloud new file mode 100755 index 0000000..caae7ed --- /dev/null +++ b/resources/usr/local/bin/instruqt-configure-gcloud @@ -0,0 +1,34 @@ +#!/bin/bash + +# INSTRUQT_GCP_PROJECTS +# INSTRUQT_GCP_PROJECT_%s_PROJECT_NAME +# INSTRUQT_GCP_PROJECT_%s_PROJECT_ID +# INSTRUQT_GCP_PROJECT_%s_USER_EMAIL +# INSTRUQT_GCP_PROJECT_%s_USER_PASSWORD +# INSTRUQT_GCP_PROJECT_%s_SERVICE_ACCOUNT_EMAIL +# INSTRUQT_GCP_PROJECT_%s_SERVICE_ACCOUNT_KEY + +gcloud_init() { + if [ -n "${INSTRUQT_GCP_PROJECTS}" ]; then + PROJECTS=("${INSTRUQT_GCP_PROJECTS//,/ }") + + # load all credentials into gcloud + for PROJECT in ${PROJECTS[@]}; do + TMP_FILE=$(mktemp) + SERVICE_ACCOUNT_KEY="INSTRUQT_GCP_PROJECT_${PROJECT}_SERVICE_ACCOUNT_KEY" + base64 -d <(echo ${!SERVICE_ACCOUNT_KEY}) > "$TMP_FILE" + gcloud auth activate-service-account --key-file="$TMP_FILE" + rm "$TMP_FILE" + done + + # activate service account for first project + SERVICE_ACCOUNT_EMAIL="INSTRUQT_GCP_PROJECT_${PROJECTS[0]}_SERVICE_ACCOUNT_EMAIL" + gcloud config set account "${!SERVICE_ACCOUNT_EMAIL}" + + # configure project + PROJECT_ID="INSTRUQT_GCP_PROJECT_${PROJECTS[0]}_PROJECT_ID" + gcloud config set project "${!PROJECT_ID}" + fi +} + +gcloud_init From ee6def327d9f869ec58d317973c6abbe2abda75e Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Mon, 30 Sep 2019 12:08:42 +0200 Subject: [PATCH 11/13] added instruqt AWS and GCloud configuration remove google-startup-scripts.service from the packer build as it was available on the ubuntu base image. the one in this repository had become incompatible. --- bootstrap.sh | 20 ++++++++----------- .../system/instruqt-configure-aws.service | 11 ++++++++++ .../system/instruqt-configure-gcloud.service | 11 ++++++++++ .../google-startup-scripts.service | 13 ------------ .../instruqt-configure-aws.service | 13 ------------ .../instruqt-configure-gcloud.service | 13 ------------ .../usr/local/bin/instruqt-configure-aws | 2 +- .../usr/local/bin/instruqt-configure-gcloud | 2 +- 8 files changed, 32 insertions(+), 53 deletions(-) create mode 100644 resources/etc/systemd/system/instruqt-configure-aws.service create mode 100644 resources/etc/systemd/system/instruqt-configure-gcloud.service delete mode 100644 resources/etc/systemd/system/multi-user.target.wants/google-startup-scripts.service delete mode 100644 resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-aws.service delete mode 100644 resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-gcloud.service diff --git a/bootstrap.sh b/bootstrap.sh index abc1170..a1d27a0 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -22,16 +22,6 @@ apt-get -y install \ software-properties-common \ jq -# workaround for missing Instruqt env. variables in check scripts -( -cat < /usr/local/bin/python3 -chmod ugo+x /usr/local/bin/python3 - # Install Docker curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add - add-apt-repository \ @@ -46,11 +36,17 @@ curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compos chmod +x /usr/local/bin/docker-compose # install cloud libraries -pip3 install awscli google-cloud 'docker[tls]' +pip3 install awscli google-cloud boto3 'docker[tls]' # install k3s curl -sfL https://get.k3s.io | sh - # Improve the startup sequence -cp -rp /tmp/resources/ / +echo "INFO: copying ./resources to /" +(cd /tmp/resources ; cp -r ./ /) +find / -name instruqt-\* +for service in $(find /tmp/resources -name \*.service); do + echo "INFO: enabling $(basename $service)" + systemctl enable $(basename $service) +done systemctl daemon-reload diff --git a/resources/etc/systemd/system/instruqt-configure-aws.service b/resources/etc/systemd/system/instruqt-configure-aws.service new file mode 100644 index 0000000..c486090 --- /dev/null +++ b/resources/etc/systemd/system/instruqt-configure-aws.service @@ -0,0 +1,11 @@ +[Unit] +Description=Instruqt AWS credentials configuration +After=google-startup-scripts.service + +[Service] +ExecStart=/usr/local/bin/instruqt-configure-aws +Type=oneshot +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/resources/etc/systemd/system/instruqt-configure-gcloud.service b/resources/etc/systemd/system/instruqt-configure-gcloud.service new file mode 100644 index 0000000..df26e30 --- /dev/null +++ b/resources/etc/systemd/system/instruqt-configure-gcloud.service @@ -0,0 +1,11 @@ +[Unit] +Description=Instruqt GCloud credentials configuration +After=google-startup-scripts.service + +[Service] +ExecStart=/usr/local/bin/instruqt-configure-gcloud +Type=oneshot +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/resources/etc/systemd/system/multi-user.target.wants/google-startup-scripts.service b/resources/etc/systemd/system/multi-user.target.wants/google-startup-scripts.service deleted file mode 100644 index e578371..0000000 --- a/resources/etc/systemd/system/multi-user.target.wants/google-startup-scripts.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Google Compute Engine Startup Scripts -After=local-fs.target network-online.target network.target rsyslog.service -After=google-instance-setup.service google-network-setup.service -Wants=local-fs.target network-online.target network.target - -[Service] -ExecStart=/usr/bin/google_metadata_script_runner --script-type startup -KillMode=process -Type=simple - -[Install] -WantedBy=multi-user.target diff --git a/resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-aws.service b/resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-aws.service deleted file mode 100644 index ba1909b..0000000 --- a/resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-aws.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Instruqt AWS credentials configuration -After=local-fs.target network-online.target network.target rsyslog.service -After=google-instance-setup.service google-network-setup.service -Wants=local-fs.target network-online.target network.target - -[Service] -ExecStart=/usr/local/bin/instruqt-configure-aws -Type=oneshot -RemainAfterExit=true - -[Install] -WantedBy=multi-user.target diff --git a/resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-gcloud.service b/resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-gcloud.service deleted file mode 100644 index 88c8e39..0000000 --- a/resources/etc/systemd/system/multi-user.target.wants/instruqt-configure-gcloud.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Instruqt GCloud credentials configuration -After=local-fs.target network-online.target network.target rsyslog.service -After=google-instance-setup.service google-network-setup.service -Wants=local-fs.target network-online.target network.target - -[Service] -ExecStart=/usr/local/bin/instruqt-configure-gcloud -Type=oneshot -RemainAfterExit=true - -[Install] -WantedBy=multi-user.target diff --git a/resources/usr/local/bin/instruqt-configure-aws b/resources/usr/local/bin/instruqt-configure-aws index 2dba0bd..f11884c 100755 --- a/resources/usr/local/bin/instruqt-configure-aws +++ b/resources/usr/local/bin/instruqt-configure-aws @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -l # Available env vars: # INSTRUQT_AWS_ACCOUNTS diff --git a/resources/usr/local/bin/instruqt-configure-gcloud b/resources/usr/local/bin/instruqt-configure-gcloud index caae7ed..08dc965 100755 --- a/resources/usr/local/bin/instruqt-configure-gcloud +++ b/resources/usr/local/bin/instruqt-configure-gcloud @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -l # INSTRUQT_GCP_PROJECTS # INSTRUQT_GCP_PROJECT_%s_PROJECT_NAME From 2c7ae2cff9011730542a166b4b0fd9c33aa5fa95 Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Mon, 30 Sep 2019 16:55:41 +0200 Subject: [PATCH 12/13] add gcloud and aws configuration once instruqt-env.sh is present --- bootstrap.sh | 7 +++---- resources/etc/systemd/system/instruqt-configure-aws.path | 7 +++++++ .../etc/systemd/system/instruqt-configure-aws.service | 6 +----- .../etc/systemd/system/instruqt-configure-gcloud.path | 7 +++++++ .../etc/systemd/system/instruqt-configure-gcloud.service | 7 +------ 5 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 resources/etc/systemd/system/instruqt-configure-aws.path create mode 100644 resources/etc/systemd/system/instruqt-configure-gcloud.path diff --git a/bootstrap.sh b/bootstrap.sh index a1d27a0..9bf9802 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -44,9 +44,8 @@ curl -sfL https://get.k3s.io | sh - # Improve the startup sequence echo "INFO: copying ./resources to /" (cd /tmp/resources ; cp -r ./ /) -find / -name instruqt-\* -for service in $(find /tmp/resources -name \*.service); do - echo "INFO: enabling $(basename $service)" - systemctl enable $(basename $service) +for cloud in aws gcloud; do + systemctl enable instruqt-configure-$cloud.path + systemctl start instruqt-configure-$cloud.path done systemctl daemon-reload diff --git a/resources/etc/systemd/system/instruqt-configure-aws.path b/resources/etc/systemd/system/instruqt-configure-aws.path new file mode 100644 index 0000000..61a6e15 --- /dev/null +++ b/resources/etc/systemd/system/instruqt-configure-aws.path @@ -0,0 +1,7 @@ +[Unit] +Description = instruqt environment settings +Wants = instruqt-configure-aws.service +[Path] +PathChanged = /etc/profile.d/instruqt-env.sh +[Install] +WantedBy = multi-user.target diff --git a/resources/etc/systemd/system/instruqt-configure-aws.service b/resources/etc/systemd/system/instruqt-configure-aws.service index c486090..c03bb3a 100644 --- a/resources/etc/systemd/system/instruqt-configure-aws.service +++ b/resources/etc/systemd/system/instruqt-configure-aws.service @@ -1,11 +1,7 @@ [Unit] Description=Instruqt AWS credentials configuration -After=google-startup-scripts.service [Service] ExecStart=/usr/local/bin/instruqt-configure-aws -Type=oneshot -RemainAfterExit=true +Type=simple -[Install] -WantedBy=multi-user.target diff --git a/resources/etc/systemd/system/instruqt-configure-gcloud.path b/resources/etc/systemd/system/instruqt-configure-gcloud.path new file mode 100644 index 0000000..b0235a1 --- /dev/null +++ b/resources/etc/systemd/system/instruqt-configure-gcloud.path @@ -0,0 +1,7 @@ +[Unit] +Description = instruqt environment settings +Wants = instruqt-configure-gcloud.service +[Path] +PathChanged = /etc/profile.d/instruqt-env.sh +[Install] +WantedBy = multi-user.target diff --git a/resources/etc/systemd/system/instruqt-configure-gcloud.service b/resources/etc/systemd/system/instruqt-configure-gcloud.service index df26e30..e0b7688 100644 --- a/resources/etc/systemd/system/instruqt-configure-gcloud.service +++ b/resources/etc/systemd/system/instruqt-configure-gcloud.service @@ -1,11 +1,6 @@ [Unit] Description=Instruqt GCloud credentials configuration -After=google-startup-scripts.service [Service] ExecStart=/usr/local/bin/instruqt-configure-gcloud -Type=oneshot -RemainAfterExit=true - -[Install] -WantedBy=multi-user.target +Type=simple From 0dbce73313365ab960186431880c9132684aa2f8 Mon Sep 17 00:00:00 2001 From: Mark van Holsteijn Date: Thu, 24 Oct 2019 15:15:47 +0200 Subject: [PATCH 13/13] add eksctl --- bootstrap.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bootstrap.sh b/bootstrap.sh index 9bf9802..b4259dc 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -41,6 +41,9 @@ pip3 install awscli google-cloud boto3 'docker[tls]' # install k3s curl -sfL https://get.k3s.io | sh - +# install eksctl +curl --silent --location "https://github.com/weaveworks/eksctl/releases/download/latest_release/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /usr/local/bin + # Improve the startup sequence echo "INFO: copying ./resources to /" (cd /tmp/resources ; cp -r ./ /)