virt-sysprep virt-customize

virt-customize -a $1.qcow2 --run-command 'yum install -y wget'

 virt-builder fedora-27 
   --hostname client.example.com 
   --update 
   --install puppet 
   --append-line '/etc/puppet/puppet.conf:[agent]' 
   --append-line '/etc/puppet/puppet.conf:server = puppetmaster.example.com/' 
   --run-command 'systemctl enable puppet' 
   --selinux-relabel
The precise instructions
[root@localhost cloud_images]#  virt-builder  vhuser-test1.qcow2  --run-command  "systemctl enable rng-tools"
 virt-builder debian-8 
   --size 20G 
   --install $pkgs 
   --edit '/etc/locale.gen: s,^#s*ja,ja,' 
   --write '/etc/default/locale:LANG="ja_JP.UTF-8"' 
   --run-command "locale-gen"

[root@localhost cloud_images]# virt-sysprep -a vhuser-test1.qcow2 --run-command "systemctl enable rng-tools"
 

[root@localhost cloud_images]#  virt-sysprep -a vhuser-test1.qcow2  --run-command  "systemctl enable rng-tools"
[   0.0] Examining the guest ...
[   4.9] Performing "abrt-data" ...
[   4.9] Performing "backup-files" ...
[   5.7] Performing "bash-history" ...
[   5.8] Performing "blkid-tab" ...
[   5.8] Performing "crash-data" ...
[   5.9] Performing "cron-spool" ...
[   5.9] Performing "dhcp-client-state" ...
[   5.9] Performing "dhcp-server-state" ...
[   5.9] Performing "dovecot-data" ...
[   6.0] Performing "logfiles" ...
[   6.0] Performing "machine-id" ...
[   6.1] Performing "mail-spool" ...
[   6.1] Performing "net-hostname" ...
[   6.3] Performing "net-hwaddr" ...
[   6.5] Performing "pacct-log" ...
[   6.6] Performing "package-manager-cache" ...
[   6.7] Performing "pam-data" ...
[   6.7] Performing "passwd-backups" ...
[   6.8] Performing "puppet-data-log" ...
[   6.8] Performing "rh-subscription-manager" ...
[   6.9] Performing "rhn-systemid" ...
[   7.0] Performing "rpm-db" ...
[   7.0] Performing "samba-db-log" ...
[   7.0] Performing "script" ...
[   7.0] Performing "smolt-uuid" ...
[   7.1] Performing "ssh-hostkeys" ...
[   7.1] Performing "ssh-userdir" ...
[   7.2] Performing "sssd-db-log" ...
[   7.2] Performing "tmp-files" ...
[   7.3] Performing "udev-persistent-net" ...
[   7.3] Performing "utmp" ...
[   7.3] Performing "yum-uuid" ...
[   7.4] Performing "customize" ...
[   7.5] Setting a random seed
[   7.5] Setting the machine ID in /etc/machine-id
[   7.5] Running: systemctl enable rng-tools
Operation failed: No such file or directory
virt-sysprep: error: systemctl enable rng-tools: command exited with an 
error

If reporting bugs, run virt-sysprep with debugging enabled and include the 
complete output:

  virt-sysprep -v -x [...]
[root@localhost cloud_images]#  virt-sysprep -a vhuser-test1.qcow2   --network --install " rng-tools"  ---有空格
[   0.0] Examining the guest ...
[   7.7] Performing "abrt-data" ...
[   7.8] Performing "backup-files" ...
[   8.6] Performing "bash-history" ...
[   8.6] Performing "blkid-tab" ...
[   8.7] Performing "crash-data" ...
[   8.7] Performing "cron-spool" ...
[   8.7] Performing "dhcp-client-state" ...
[   8.8] Performing "dhcp-server-state" ...
[   8.8] Performing "dovecot-data" ...
[   8.8] Performing "logfiles" ...
[   8.9] Performing "machine-id" ...
[   8.9] Performing "mail-spool" ...
[   8.9] Performing "net-hostname" ...
[   9.2] Performing "net-hwaddr" ...
[   9.4] Performing "pacct-log" ...
[   9.5] Performing "package-manager-cache" ...
[   9.5] Performing "pam-data" ...
[   9.6] Performing "passwd-backups" ...
[   9.6] Performing "puppet-data-log" ...
[   9.7] Performing "rh-subscription-manager" ...
[   9.7] Performing "rhn-systemid" ...
[   9.8] Performing "rpm-db" ...
[   9.9] Performing "samba-db-log" ...
[   9.9] Performing "script" ...
[   9.9] Performing "smolt-uuid" ...
[  10.0] Performing "ssh-hostkeys" ...
[  10.0] Performing "ssh-userdir" ...
[  10.0] Performing "sssd-db-log" ...
[  10.1] Performing "tmp-files" ...
[  10.1] Performing "udev-persistent-net" ...
[  10.2] Performing "utmp" ...
[  10.2] Performing "yum-uuid" ...
[  10.3] Performing "customize" ...
[  10.3] Setting a random seed
[  10.4] Setting the machine ID in /etc/machine-id
[  10.4] Installing packages:  rng-tools
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror-hk.koddos.net
 * extras: mirror-hk.koddos.net
 * updates: mirror-hk.koddos.net
No package  rng-tools available.
Error: Nothing to do
virt-sysprep: error: yum -y install ' rng-tools': command exited with an 
error

If reporting bugs, run virt-sysprep with debugging enabled and include the 
complete output:

  virt-sysprep -v -x [...]
[root@localhost cloud_images]#  virt-sysprep -a vhuser-test1.qcow2   --network --install "rng-tools"
[   0.0] Examining the guest ...
[   7.9] Performing "abrt-data" ...
[   8.0] Performing "backup-files" ...
[   8.8] Performing "bash-history" ...
[   8.8] Performing "blkid-tab" ...
[   8.9] Performing "crash-data" ...
[   8.9] Performing "cron-spool" ...
[   8.9] Performing "dhcp-client-state" ...
[   9.0] Performing "dhcp-server-state" ...
[   9.0] Performing "dovecot-data" ...
[   9.0] Performing "logfiles" ...
[   9.1] Performing "machine-id" ...
[   9.1] Performing "mail-spool" ...
[   9.1] Performing "net-hostname" ...
[   9.3] Performing "net-hwaddr" ...
[   9.6] Performing "pacct-log" ...
[   9.7] Performing "package-manager-cache" ...
[   9.8] Performing "pam-data" ...
[   9.8] Performing "passwd-backups" ...
[   9.8] Performing "puppet-data-log" ...
[   9.9] Performing "rh-subscription-manager" ...
[  10.0] Performing "rhn-systemid" ...
[  10.0] Performing "rpm-db" ...
[  10.1] Performing "samba-db-log" ...
[  10.1] Performing "script" ...
[  10.1] Performing "smolt-uuid" ...
[  10.2] Performing "ssh-hostkeys" ...
[  10.2] Performing "ssh-userdir" ...
[  10.3] Performing "sssd-db-log" ...
[  10.3] Performing "tmp-files" ...
[  10.3] Performing "udev-persistent-net" ...
[  10.4] Performing "utmp" ...
[  10.4] Performing "yum-uuid" ...
[  10.5] Performing "customize" ...
[  10.5] Setting a random seed
[  10.6] Setting the machine ID in /etc/machine-id
[  10.6] Installing packages: rng-tools
[  16.5] Performing "lvm-uuids" ...
[root@localhost cloud_images]# 
原文地址:https://www.cnblogs.com/dream397/p/13930443.html