~codyshepherd/livecd-rootfs/xenial-proposed-snaps-manifest

« back to all changes in this revision

Viewing changes to live-build/ubuntu-cpc/hooks/042-vagrant.binary

Changed default user configuration in the vagrant image, in accordance with the vagrant community's expectations

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
# avoid pulling into a cloud image.
59
59
chroot ${mount_d} apt-get install --no-install-recommends -y virtualbox-guest-utils
60
60
chroot ${mount_d} apt-get clean
 
61
 
 
62
# Create and setup users inside the image.
 
63
# Vagrant users expect a "vagrant" user with a "vagrant" username.
 
64
# See https://www.vagrantup.com/docs/boxes/base.html
 
65
# Note: We decided NOT to allow root login with a default password.
 
66
chroot ${mount_d} adduser vagrant
 
67
echo "vagrant:vagrant" | chroot ${mount_d} chpasswd
 
68
 
 
69
# The vagrant user should have passwordless sudo.
 
70
cat << EOF > ${mount_d}/etc/sudoers.d/vagrant
 
71
vagrant ALL=(ALL) NOPASSWD:ALL
 
72
EOF
 
73
 
 
74
# Add the insecure vagrant pubkey to the vagrant user, as is expected by the
 
75
# vagrant ecosystem (https://www.vagrantup.com/docs/boxes/base.html)
 
76
chroot ${mount_d} chmod 0440 /etc/sudoers.d/vagrant
 
77
chroot ${mount_d} mkdir -p /home/vagrant/.ssh
 
78
cat << EOF > ${mount_d}/home/vagrant/.ssh/authorized_keys
 
79
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
 
80
EOF
 
81
chroot ${mount_d} chown -R vagrant:vagrant /home/vagrant/.ssh
 
82
chroot ${mount_d} chmod 700 /home/vagrant/.ssh
 
83
 
61
84
umount_disk_image "$mount_d"
62
85
rmdir "$mount_d"
63
86
 
71
94
vmdk_f="${box_d}/${prefix}.vmdk"
72
95
create_vmdk ${derivative_img} ${vmdk_f}
73
96
 
74
 
# Vagrant needs a base user. We either inject the well-known SSH key
75
 
# or use password authentication. Both are ugly. So we'll use a password
76
 
# and make it random. This obviously is insecure...but at least its
77
 
# better than the alternatives.
78
 
ubuntu_user_pass=$(openssl rand -hex 12)
79
 
 
80
97
####################################
81
98
# Create the ConfigDrive
82
99
# This is a cloud-init piece that instructs cloud-init to configure
89
106
# except via local host.
90
107
cat > ${seed_d}/user-data <<END
91
108
#cloud-config
92
 
password: ${ubuntu_user_pass}
93
 
chpasswd: { expire: False }
94
 
ssh_pwauth: True
95
109
manage_etc_hosts: localhost
96
110
END
97
111
 
132
146
 
133
147
Vagrant.configure("2") do |config|
134
148
  config.vm.base_mac = "${macaddr}"
135
 
  config.ssh.username = "ubuntu"
136
 
  config.ssh.password = "${ubuntu_user_pass}"
137
149
 
138
150
  config.vm.provider "virtualbox" do |vb|
139
151
     vb.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ]