Allow setting of Sysprep options and multiple hyperv features (#1089)

Allow setting of multiple hyperv features and support for virt-sysprep options

Fixes #1039 and #1077
This commit is contained in:
Michael Ablassmeier 2020-04-21 12:37:03 +02:00 committed by GitHub
parent 5658a83723
commit d39a9a302a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -1458,6 +1458,14 @@ documentation](http://libguestfs.org/virt-sysprep.1.html#operations) for
further details especially on default sysprep operations enabled for
your system.
Options to the virt-sysprep command call can be passed via
`VAGRANT_LIBVIRT_VIRT_SYSPREP_OPTIONS` environment variable.
```shell
$ export VAGRANT_LIBVIRT_VIRT_SYSPREP_OPTIONS="--delete /etc/hostname"
$ vagrant package
```
For example, on Chef [bento](https://github.com/chef/bento) VMs that
require SSH hostkeys already set (e.g. bento/debian-7) as well as leave
existing LVM UUIDs untouched (e.g. bento/ubuntu-18.04), these can be

View File

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

View File

@ -355,7 +355,10 @@ module VagrantPlugins
raise 'Feature name AND state must be specified'
end
@features_hyperv = [{name: options[:name], state: options[:state]}] if @features_hyperv == UNSET_VALUE
@features_hyperv = [] if @features_hyperv == UNSET_VALUE
@features_hyperv.push(name: options[:name],
state: options[:state])
end
def cputopology(options = {})