From a9ef86e37fe77a728b175831bd7d3d928edd054b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Sun, 16 Apr 2017 01:36:47 +0200 Subject: [PATCH] add: script to create base image Change-Id: I0471d7463a6cfc5b406137146392e1fd1825f44f --- manager/README.md | 2 +- manager/init-vm | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 manager/init-vm diff --git a/manager/README.md b/manager/README.md index c54e6c2..1ee65bf 100644 --- a/manager/README.md +++ b/manager/README.md @@ -12,7 +12,6 @@ In the following instruction "this directory" refers to the directory (outside o - create an ssh-key (may have a passphrase) named "vm-key" in this directory - install the public key into the VMs authorized_keys-file (e.g. with `ssh-copy-id`) - create a file named `/config` containing `to=user@vm-connection-info` - (steps 4 and 5 can be executed by script init-vm) 4. connect to this VM and install CI-SSH-Key (generate one named vm-key in this directory) - (optional) disable SSH-Password Auth (in the VM) - (optional; required for CI) disable sudo requiring a password. (in the VM) @@ -22,6 +21,7 @@ In the following instruction "this directory" refers to the directory (outside o 8. run `./setup [fresh]` - `fresh` instructs the script to reset the VM before installing +(Steps 4 and 6 can be guided by the script "init-vm".) Creating a tricks script ------ diff --git a/manager/init-vm b/manager/init-vm new file mode 100644 index 0000000..d373931 --- /dev/null +++ b/manager/init-vm @@ -0,0 +1,17 @@ +#!/bin/bash +source $1/config +ssh-copy-id -i vm-key $to +echo "Please add the following line to your sudoers file." +echo "%sudo ALL=(ALL) NOPASSWD:ALL" +read -rp 'Press Enter to visudo.' _ +ssh -t -i vm-key $to "sudo visudo" +read -rp "The ssh-key to access the VM has been installed therefore ssh password authentication is not needed anymore. It's best to disable password authentication now in the sshd config file. Press Enter to edit the file." _ +ssh -t -i vm-key $to "sudo -e /etc/ssh/sshd_config && sudo systemctl reload ssh" + +# ci-speedup +read -rp 'We are done. Continue with additional setup to speed up CI builds? [y/N] ' prompt +if [[ $prompt == "y" ]]; then + ssh -i vm-key $to 'sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install -y git emacs-nox tmux curl puppet puppet-master lxc' + ssh -i vm-key $to 'sudo lxc-create -n base-image -t debian -- -r stretch --packages=gnupg2,puppet,lsb-release,debconf-utils' + ssh -i vm-key $to 'sudo rm -r /var/lib/lxc/base-image/rootfs/var/lib/apt/lists"' +fi -- 2.39.2