Allow customizing of virt-sysprep behaviour on package (#955)

Support `vagrant package` of e.g. bento-derived boxes that require SSH
hostkeys already set (as in the case of bento/debian-7 and above,) as
well as leave existing LVM UUIDs untouched (e.g. in bento/ubuntu-18.04.)

Instead of hard-coding sysprep operations, use an environment variable
to set these instead.

Use the Chef bento use case as an example for customizing sysprep
operations.
This commit is contained in:
Zak B. Elep
2019-02-27 20:32:37 +08:00
committed by Darragh Bailey
parent 3d0080b6a4
commit deb36bef8b
2 changed files with 25 additions and 1 deletions

View File

@@ -38,7 +38,8 @@ module VagrantPlugins
`qemu-img rebase -p -b "" #{@tmp_img}`
# remove hw association with interface
# working for centos with lvs default disks
`virt-sysprep --no-logfile --operations defaults,-ssh-userdir -a #{@tmp_img}`
operations = ENV.get('VAGRANT_LIBVIRT_VIRT_SYSPREP_OPERATIONS', 'defaults,-ssh-userdir')
`virt-sysprep --no-logfile --operations #{operations} -a #{@tmp_img}`
# add any user provided file
extra = ''
@tmp_include = @tmp_dir + '/_include'