From 7008996882977ffe9ffef61c133bda507092a620 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 26 Aug 2012 22:16:22 +0100 Subject: Add preliminary script to create Jenkins VM image --- vm-data/common.conf | 7 +++++ vm-data/jenkins.conf | 7 +++++ vm-data/jenkins.customize | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 vm-data/common.conf create mode 100644 vm-data/jenkins.conf create mode 100755 vm-data/jenkins.customize (limited to 'vm-data') diff --git a/vm-data/common.conf b/vm-data/common.conf new file mode 100644 index 0000000..19536c3 --- /dev/null +++ b/vm-data/common.conf @@ -0,0 +1,7 @@ +[config] +log = vmdebootstrap.log +mirror = http://cdn.debian.net/debian +enable-dhcp = yes +arch = amd64 +size = 10G +verbose = yes diff --git a/vm-data/jenkins.conf b/vm-data/jenkins.conf new file mode 100644 index 0000000..7a4fa71 --- /dev/null +++ b/vm-data/jenkins.conf @@ -0,0 +1,7 @@ +[config] +distribution = squeeze +hostname = jenkins +image = jenkins.img +customize = vm-data/jenkins.customize +package = bzr, git, ssh, vim, less, rsync, apache2, reprepro + diff --git a/vm-data/jenkins.customize b/vm-data/jenkins.customize new file mode 100755 index 0000000..b181303 --- /dev/null +++ b/vm-data/jenkins.customize @@ -0,0 +1,70 @@ +#!/bin/sh +# +# vm-data/jenkins.customize - customize disk image for jenkins master node +# +# Copyright 2012 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -eux + +export LC_ALL=C + +rootdir="$1" + +# Create a policy-rc.d so that nothing starts during the install. +cat < "$rootdir/usr/sbin/policy-rc.d" +#!/bin/sh +exit 101 +EOF +chmod a+x "$rootdir/usr/sbin/policy-rc.d" + +# Add the Jenkins apt repository to sources.list. +cat <> "$rootdir/etc/apt/sources.list" +deb http://pkg.jenkins-ci.org/debian binary/ +EOF + +# Add extra signing keys into apt's keyring. +wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | + chroot "$rootdir" apt-key add - +wget -q -O - http://code.liw.fi/apt.asc | + chroot "$rootdir" apt-key add - + +# Update apt's package lists. +chroot "$rootdir" apt-get update + +# Create a user for Jenkins, with home directory, and then install Jenkins. +# We mount /proc while doing this, because otherwise some packages fail +# to install correctly. +mount -t proc proc "$rootdir/proc" +chroot "$rootdir" adduser --gecos 'Jenkins' \ + --disabled-password --home=/var/lib/jenkins jenkins +chroot "$rootdir" install -d -o jenkins -g jenkins /var/lib/jenkins +chroot "$rootdir" apt-get install -y --no-remove jenkins +umount "$rootdir/proc" + +# Remove the policy-rc.d so that things do start when we boot into the system. +rm "$rootdir/usr/sbin/policy-rc.d" + +# Install ssh host keys. +install -m 0600 vm-data/jenkins.host-key "$rootdir/etc/ssh/ssh_host_rsa_key" +install -m 0644 vm-data/jenkins.host-key.pub \ + "$rootdir/etc/ssh/ssh_host_rsa_key.pub" + +# Install the worker user key into Jenkins's allowed_keys file. +mkdir -m 0700 "$rootdir/var/lib/jenkins/.ssh" +cp vm-data/worker.user-key.pub "$rootdir/var/lib/jenkins/.ssh/authorized_keys" +chmod 0600 "$rootdir/var/lib/jenkins/.ssh/authorized_keys" +chroot "$rootdir" chown -R jenkins:jenkins /var/lib/jenkins/.ssh/. + -- cgit v1.2.1