CentOS provides cloud images for various cloud environments such as Openstack, RHV, Azure, or just KVM. It is possible to alter user passwords or SSH keys on these images without using cloud-init! This is nifty for use in Jenkins, Packer, local dev work or other use cases to just write changes to the image so it is ready to go. Check this out!
Pre-req: make sure to have the package libguestfs-tools installed (Debian or Fedora)!
# sudo apt install libguestfs-tools
The command virt-customize can edit images in a variety of ways. Here are some examples to get you started:
Set a random root password in the image
# sudo virt-customize -a CentOS-7-x86_64-GenericCloud.qcow2 --root-password random
[ 0.0] Examining the guest ...
[ 11.2] Setting a random seed
[ 11.2] Setting passwords
virt-customize: Setting random password of root to 132Tfe6cfCCr8Pv8
[ 12.2] Finishing off
Set a specific root password of: centos
# sudo virt-customize -a CentOS-7-x86_64-GenericCloud.qcow2 --root-password password:centos
[ 0.0] Examining the guest ...
[ 12.1] Setting a random seed
[ 14.5] Setting passwords
[ 15.9] Finishing off
[ 12.1] Setting a random seed
[ 14.5] Setting passwords
[ 15.9] Finishing off
Comments
Post a Comment