1
0

Add vagrant file for generate centos image

This commit is contained in:
dump_stack() 2018-10-07 12:43:15 +00:00
parent 6991877493
commit 65a34d8ec8
2 changed files with 38 additions and 0 deletions

2
tools/qemu-centos-img/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.img
.vagrant

36
tools/qemu-centos-img/Vagrantfile vendored Normal file
View File

@ -0,0 +1,36 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.synced_folder ".", "/vagrant", type: 'virtualbox'
config.vm.provision "shell", inline: <<-SHELL
yum -y install qemu-img e2fsprogs
qemu-img create centos7.img 8G
mkfs.ext4 -F centos7.img
TMPDIR=$(mktemp -d)
mount -o loop centos7.img $TMPDIR
yum --installroot=$TMPDIR \
--releasever=7 \
--disablerepo='*' \
--enablerepo=base \
-y groupinstall Base
yum --installroot=$TMPDIR \
--releasever=7 \
--disablerepo='*' \
--enablerepo=base \
-y install openssh-server
chroot $TMPDIR /bin/sh -c 'useradd -m user'
sed -i 's/root:\*:/root::/' $TMPDIR/etc/shadow
sed -i 's/user:!!:/user::/' $TMPDIR/etc/shadow
echo auth sufficient pam_permit.so > $TMPDIR/etc/pam.d/sshd
sed -i '/PermitEmptyPasswords/d' $TMPDIR/etc/ssh/sshd_config
echo PermitEmptyPasswords yes >> $TMPDIR/etc/ssh/sshd_config
sed -i '/PermitRootLogin/d' $TMPDIR/etc/ssh/sshd_config
echo PermitRootLogin yes >> $TMPDIR/etc/ssh/sshd_config
umount $TMPDIR
cp centos7.img /vagrant/
SHELL
end