diff options
author | Lars Wirzenius <liw@liw.fi> | 2015-07-03 21:16:48 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2015-07-03 21:16:48 +0300 |
commit | 891748b0b1c74db04bfb75932e35b0ef62e746e2 (patch) | |
tree | 42334620f0dfb8ba1c6779de2aab15f12271a034 /vmdebootstrap | |
download | ansibleness-891748b0b1c74db04bfb75932e35b0ef62e746e2.tar.gz |
Initial commit
Diffstat (limited to 'vmdebootstrap')
-rw-r--r-- | vmdebootstrap/authorized_keys | 1 | ||||
-rwxr-xr-x | vmdebootstrap/base-create.sh | 17 | ||||
-rw-r--r-- | vmdebootstrap/base-debian8-amd64.conf | 5 | ||||
-rw-r--r-- | vmdebootstrap/base.conf | 10 | ||||
-rwxr-xr-x | vmdebootstrap/base.customize | 46 |
5 files changed, 79 insertions, 0 deletions
diff --git a/vmdebootstrap/authorized_keys b/vmdebootstrap/authorized_keys new file mode 100644 index 0000000..b7e5273 --- /dev/null +++ b/vmdebootstrap/authorized_keys @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzc5k+s8dm6zwxlfgIAUVY8x1UPOXDnxLgIpMbS7DuHmtpo7a6doFRGdaPnQStteliLWmmggVwh5q3PPvgegTT6SIc3mPoL3UK/2bnkU+wGwUfhykP/Uulhtzr6Dsr3vgTNp6dFCvSd5ZEb+ih9I9nRviWM9vDYXccc4jKoxb9Zepb6QWp3F8dPpUFEf6GbH+WunE2TFj8aJ5f4R77phpof+vLfiJyV0QTUVpf3BYPfnnmbOVLy/3t4YvdUde+FMdXiWwmfb35ZNmRqpD0U4jzFVGg2TgeGXCu18kva04i20S2yrQEY5oQndnaRZdbWa7Hp83WRIuk1d0X1TXViVPcw== liw diff --git a/vmdebootstrap/base-create.sh b/vmdebootstrap/base-create.sh new file mode 100755 index 0000000..c20eefd --- /dev/null +++ b/vmdebootstrap/base-create.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# +# Create all missing disk images. +# This needs to be run as root, from the directory it exists in. + +set -eu + +for conf in $(find . -maxdepth 1 -name 'base-*.conf') +do + img=$(vmdebootstrap --config base.conf --config "$conf" --dump-config | + awk '$1 == "image" { print $3 }') + if [ ! -e "$img" ] + then + echo "==== Building $conf" + vmdebootstrap --config base.conf --config "$conf" + fi +done diff --git a/vmdebootstrap/base-debian8-amd64.conf b/vmdebootstrap/base-debian8-amd64.conf new file mode 100644 index 0000000..515df48 --- /dev/null +++ b/vmdebootstrap/base-debian8-amd64.conf @@ -0,0 +1,5 @@ +[config] +arch = amd64 +distribution = jessie +hostname = base +image = base-debian8-amd64.img diff --git a/vmdebootstrap/base.conf b/vmdebootstrap/base.conf new file mode 100644 index 0000000..f6b45c0 --- /dev/null +++ b/vmdebootstrap/base.conf @@ -0,0 +1,10 @@ +[config] +mirror = http://192.168.122.1/debian +enable-dhcp = yes +size = 4G +verbose = no +grub = yes +sparse = yes +sudo = yes +package = ssh, python +customize = ./base.customize diff --git a/vmdebootstrap/base.customize b/vmdebootstrap/base.customize new file mode 100755 index 0000000..9c007f7 --- /dev/null +++ b/vmdebootstrap/base.customize @@ -0,0 +1,46 @@ +#!/bin/sh +# +# base.customize - configure base disk image for management by ansible +# +# This sets up a very basic image, just enough to allow ansible to log +# in and become root with sudo. All the rest of the configuration +# happens via ansible. +# +# Copyright 2015 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 <http://www.gnu.org/licenses/>. + + +set -eu + +# Avoid any problems (mainly weird perl warnings) from inherited +# locale from user. +export LC_ALL=C + +rootdir="$1" + +# Create an account for ansible. +chroot "$rootdir" adduser --gecos 'Ansible' --disabled-password ansible + +# Install an authorize_keys file so that ansible can access the account. +chroot "$rootdir" install -d -o ansible -g ansible -m 0700 /home/ansible/.ssh +install -m 0600 authorized_keys "$rootdir/home/ansible/.ssh/authorized_keys" +chroot "$rootdir" chown ansible:ansible /home/ansible/.ssh/authorized_keys + +# Add ansible to sudoers, without password. +cat <<EOF >> "$rootdir/etc/sudoers.d/ansible" +ansible ALL=(ALL:ALL) NOPASSWD: ALL +EOF +chroot "$rootdir" chown root:root /etc/sudoers.d/ansible +chroot "$rootdir" chmod 0440 /etc/sudoers.d/ansible |