Commit 94ee3645 authored by Michael Pöhn's avatar Michael Pöhn

preseed vagrants default ssh key to virtualbox VMs

parent 891f967d
......@@ -24,7 +24,6 @@ import stat
import logging
import tarfile
import tempfile
import textwrap
import subprocess
from argparse import ArgumentParser
......@@ -110,13 +109,8 @@ def init_params(provider, workdir='.'):
def write_bootstrap_script(path, username):
with open(path, 'w') as f:
f.write(textwrap.dedent("""\
#! /bin/sh
set -e
VMROOT=$1
echo '{username} ALL=(ALL) NOPASSWD: ALL' >> $VMROOT/etc/sudoers
""").format(username=username))
f.write(get_resource_as_string('debootstrap-custom.sh')
.format(username=username))
st = os.stat(path)
os.chmod(path, st.st_mode |
stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
......@@ -146,13 +140,12 @@ def exec_vmdebootstrap(params, provider, verbose=False, dry_run=False):
cmd = [x for x in cmd if x is not None] # strip nones
if provider == 'virtualbox':
cmd += ['--debootstrapopts=components=main,contrib']
if dry_run:
cmd += ['--dry-run']
logging.debug('> {}'.format(' '.join(cmd)))
if not dry_run:
logging.info('running vmdebootstrap (please be patient, '
'this may take several minutes) ...')
subprocess.call(cmd)
else:
logging.info('(dry run) Skip running vmdebootstrap')
logging.info('running vmdebootstrap (please be patient, '
'this may take several minutes) ...')
subprocess.call(cmd)
def libvirt_convert_raw_to_qcow2(params, verbose=False, dry_run=False):
......
#! /bin/sh
set -e
VMROOT=$1
echo '{username} ALL=(ALL) NOPASSWD: ALL' >> $VMROOT/etc/sudoers
VGRNT_UID=`ls -ln $VMROOT/home | grep vagrant | awk '{{print $3}}'`
VGRNT_GID=`ls -ln $VMROOT/home | grep vagrant | awk '{{print $4}}'`
mkdir $VMROOT/home/vagrant/.ssh
chmod 700 $VMROOT/home/vagrant/.ssh
chown $VGRNT_UID:$VGRNT_GID $VMROOT/home/vagrant/.ssh
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant_insecure_public_key" > $VMROOT/home/vagrant/.ssh/authorized_keys
chmod 600 $VMROOT/home/vagrant/.ssh/authorized_keys
chown $VGRNT_UID:$VGRNT_GID $VMROOT/home/vagrant/.ssh/authorized_keys
echo 'DEBUG +++ DEBUG +++ DEBUG +++ DEBUG +++ DEBUG +++ DEBUG +++ DEBUG'
ls -al $VMROOT/home/vagrant/
ls -al $VMROOT/home/vagrant/.ssh
......@@ -3,8 +3,6 @@ Vagrant::Config.run do |config|
# the MAC address of the box. Custom configuration should be placed in
# the actual `Vagrantfile` in this box.
config.vm.base_mac = "080027E8A88A"
config.ssh.username = "{username}"
config.ssh.password = "{password}"
end
# Load include vagrant file if it exists after the auto-generated
......
Vagrant.configure("2") do |config|
config.vm.box = "fdroid-jessie64"
config.ssh.password = "vagrant"
config.ssh.username = "vagrant"
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment