diff --git a/README.md b/README.md index d2a6685..5858ff6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/vagrant-libvirt/action/package_domain.rb b/lib/vagrant-libvirt/action/package_domain.rb index c767fce..3027aad 100644 --- a/lib/vagrant-libvirt/action/package_domain.rb +++ b/lib/vagrant-libvirt/action/package_domain.rb @@ -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' diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index 0661fa8..89feb92 100644 --- a/lib/vagrant-libvirt/config.rb +++ b/lib/vagrant-libvirt/config.rb @@ -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 = {})