]> WPIA git - infra.git/commitdiff
add: script to create base image
authorFelix Dörre <felix@dogcraft.de>
Sat, 15 Apr 2017 23:36:47 +0000 (01:36 +0200)
committerFelix Dörre <felix@dogcraft.de>
Sat, 22 Apr 2017 22:06:59 +0000 (00:06 +0200)
Change-Id: I0471d7463a6cfc5b406137146392e1fd1825f44f

manager/README.md
manager/init-vm [new file with mode: 0644]

index c54e6c2ac4e5839efb430c208cdee0ab6251d7e7..1ee65bfcaf3196b1a3ae65b5ee97af4ed19d78b5 100644 (file)
@@ -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 `<myconfname>/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 <myconfname> [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 (file)
index 0000000..d373931
--- /dev/null
@@ -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