Fix vagrant up with ubuntu/xenial64

There is the following bug in ubuntu/xenial64 cloud image.
https://bugs.launchpad.net/cloud-images/+bug/1569237
This will cause that vagrant user will not exist.

Change-Id: Iacc4135fa165d8624ad61c4e5170683180234cbf
Closes-Bug: #1687197
This commit is contained in:
Liping Mao (limao)
2017-04-29 21:55:51 +08:00
parent 3e2891d6fc
commit ea12e966ee
2 changed files with 24 additions and 0 deletions

View File

@@ -30,6 +30,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
v.video_type = 'qxl'
end
config.ssh.username = "ubuntu"
config.vm.provision "shell", path: "add_vagrant_user.sh"
config.vm.synced_folder '../../devstack/', '/devstack'
# For CentOS machines it needs to be specified
config.vm.synced_folder '.', '/vagrant'

View File

@@ -0,0 +1,21 @@
#!/bin/bash
echo "create user vagrant"
adduser --disabled-password --gecos "" vagrant
echo 'vagrant:vagrant' | chpasswd
ls -al /home/
echo "add sudo privilege to user vagrant"
cp /etc/sudoers.d/90-cloud-init-users /etc/sudoers.d/admin
chmod +w /etc/sudoers.d/admin
ls -al /etc/sudoers.d/
sed -i 's/ubuntu/vagrant/g' /etc/sudoers.d/admin
cat /etc/sudoers.d/admin
echo "enable ssh access for user vagrant"
mkdir /home/vagrant/.ssh
cat /home/ubuntu/.ssh/authorized_keys > /home/vagrant/.ssh/authorized_keys
chown vagrant:vagrant -R /home/vagrant/.ssh
su - vagrant -c "cat /home/vagrant/.ssh/authorized_keys"
chmod 600 /home/vagrant/.ssh/authorized_keys
ls -al /home/vagrant/.ssh
chmod 700 /home/vagrant/.ssh
ls -al /home/vagrant