From 611fe55e906df13a572de39f403dd656ef2404b6 Mon Sep 17 00:00:00 2001 From: Maxime Deravet Date: Tue, 31 Jul 2018 06:24:16 -0700 Subject: [PATCH] Allow to configure docker password using the settings file (#317) --- prepare-vms/README.md | 2 +- prepare-vms/cards.html | 2 +- prepare-vms/lib/postprep.py | 5 +++-- prepare-vms/settings/example.yaml | 3 +++ prepare-vms/settings/fundamentals.yaml | 3 +++ prepare-vms/settings/kube101.html | 2 +- prepare-vms/settings/kube101.yaml | 3 +++ prepare-vms/settings/swarm.yaml | 3 +++ 8 files changed, 18 insertions(+), 5 deletions(-) diff --git a/prepare-vms/README.md b/prepare-vms/README.md index 9b3d1ef2..7ce1483f 100644 --- a/prepare-vms/README.md +++ b/prepare-vms/README.md @@ -93,7 +93,7 @@ wrap Run this program in a container - The `./workshopctl` script can be executed directly. - It will run locally if all its dependencies are fulfilled; otherwise it will run in the Docker container you created with `docker-compose build` (preparevms_prepare-vms). - During `start` it will add your default local SSH key to all instances under the `ubuntu` user. -- During `deploy` it will create the `docker` user with password `training`, which is printing on the cards for students. For now, this is hard coded. +- During `deploy` it will create the `docker` user with password `training`, which is printing on the cards for students. This can be configured with the `docker_user_password` property in the settings file. ### Example Steps to Launch a Batch of AWS Instances for a Workshop diff --git a/prepare-vms/cards.html b/prepare-vms/cards.html index 1cf0260c..e138f2e4 100644 --- a/prepare-vms/cards.html +++ b/prepare-vms/cards.html @@ -85,7 +85,7 @@ img { login: docker password: - training + {{ docker_user_password }}}

diff --git a/prepare-vms/lib/postprep.py b/prepare-vms/lib/postprep.py index 1c4ed4d9..c0d4466a 100755 --- a/prepare-vms/lib/postprep.py +++ b/prepare-vms/lib/postprep.py @@ -13,6 +13,7 @@ COMPOSE_VERSION = config["compose_version"] MACHINE_VERSION = config["machine_version"] CLUSTER_SIZE = config["clustersize"] ENGINE_VERSION = config["engine_version"] +DOCKER_USER_PASSWORD = config["docker_user_password"] ################################# @@ -54,9 +55,9 @@ system("curl --silent {} > /tmp/ipv4".format(ipv4_retrieval_endpoint)) ipv4 = open("/tmp/ipv4").read() -# Add a "docker" user with password "training" +# Add a "docker" user with password coming from the settings system("id docker || sudo useradd -d /home/docker -m -s /bin/bash docker") -system("echo docker:training | sudo chpasswd") +system("echo docker:{} | sudo chpasswd".format(DOCKER_USER_PASSWORD)) # Fancy prompt courtesy of @soulshake. system("""sudo -u docker tee -a /home/docker/.bashrc <login: docker password: - training + {{ docker_user_password }}

diff --git a/prepare-vms/settings/kube101.yaml b/prepare-vms/settings/kube101.yaml index 9808c0b0..fbbfcccb 100644 --- a/prepare-vms/settings/kube101.yaml +++ b/prepare-vms/settings/kube101.yaml @@ -22,3 +22,6 @@ engine_version: stable # These correspond to the version numbers visible on their respective GitHub release pages compose_version: 1.21.1 machine_version: 0.14.0 + +# Password used to connect with the "docker user" +docker_user_password: training \ No newline at end of file diff --git a/prepare-vms/settings/swarm.yaml b/prepare-vms/settings/swarm.yaml index d61c2b90..55636ae0 100644 --- a/prepare-vms/settings/swarm.yaml +++ b/prepare-vms/settings/swarm.yaml @@ -22,3 +22,6 @@ engine_version: stable # These correspond to the version numbers visible on their respective GitHub release pages compose_version: 1.21.1 machine_version: 0.14.0 + +# Password used to connect with the "docker user" +docker_user_password: training \ No newline at end of file