config in cloud image

change cloud image default config

install package

1
2
3
sudo yum install -y libguestfs-tools
# or
sudo yum install -y libguestfs-tools-c

Set root password

1
virt-customize -a rhel-server-7.6.qcow2 --root-password password:StrongRootPassword

Register System

1
2
3
virt-customize -a overcloud-full.qcow2 --run-command 'subscription-manager register --username=[username] --password=[password]'

virt-customize -a rhel-server-7.6.qcow2 --run-command 'subscription-manager attach --pool [subscription-pool]'

Install Software packages inside an image

1
2
3
virt-customize -a rhel-server-7.6.qcow2 --install [vim,bash-completion,wget,curl,telnet,unzip]

virt-customize -a rhel-server-7.6.qcow2 --install net-tools

Upload SSH public key

1
2
3
4
5
# set ssh-key for a user(The user must exist in image)
virt-customize -a rhel-server-7.6.qcow2 --ssh-inject root:file:./id_rsa.pub
# or
virt-customize -a rhel-server-7.6.qcow2 --run-command 'useradd mystic' \
--ssh-inject mystic:file:~/.ssh/id_rsa.pub

Uploading files

1
2
3
4
5
virt-customize -a rhel-server-7.6.qcow2 --upload rhsm.conf:/etc/rhsm/rhsm.conf

virt-customize -a rhel-server-7.6.qcow2 --upload yum.conf:/etc/yum.conf

virt-customize -a rhel-server-7.6.qcow2 --upload proxy.sh:/etc/profile.d/

The format: local_file_path:image_file_path

Set Timezone

1
virt-customize -a rhel-server-7.6.qcow2 --timezone "Asia/Shanghai"

Relabel SELinux

1
virt-customize -a rhel-server-7.6.qcow2 --selinux-relabel