I am trying to install several kvm's with ansible and virt-install using kickstart file.
tasks:
- name: Create VMs
command: /usr/bin/virt-install --connect=qemu:///system --network network=default
--initrd-inject=/tmp/anaconda-ks.cfg
--extra-args="console=tty0 console=ttyS0,115200 serial rd_NO_PLYMOUTH ks=file:/anaconda-ks.cfg"
--name={{ item }}
--disk path=/var/lib/libvirt/images/{{ item }}.qcow2,format=qcow2,size=10,cache=none
--ram 1024 --vcpus=1 --check-cpu --accelerate
--os-type linux --os-variant fedora19 --hvm
--location=/tmp/Fedora-20-x86_64-DVD.iso --nographics
with_items:
- vm1
- vm2
- vm3
The question is how to make "--hostname= {{ item }}" in kickstart file (/tmp/anaconda-ks.cfg) replaced dynamically for each vm. So that after install each vm will be with its own hostname.