I have created an environment with several Linux hosts based on KVM. I'm using virt-manager to create different VMs and I'm using Linux bridges to create connectivity between VMs in different hosts.
Now, I would like to have an auto-configuration server so that my VMs can auto-configure their name, IP address, run some scripts, etc based on a unique id that each of them has. Is it possible to replicate a sort of cloud-init setup in a non-openstack environment?
I have tried using cloud-init the datasource NoCloud in the following way. First, I have installed cloud-init in the VM and configured cloud.cfg:
datasource:
NoCloud
datasource_list: [ NoCloud ]
disable_ec2_metadata: True
Then, I have created a user-data file and meta-data file with the following content:
user-data:
#cloud-config
hostname: prueba
password: passw0rd
chpasswd: { expire: False }
ssh_pwauth: True
meta-data:
instance-id: iid-local01
local-hostname: prueba
Then, I have generated an iso file:
genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data
Finally, I have attached the disk to the VM and started it. This is the relevant part of the XML:
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/opt/images/seed.iso'/>
<backingStore/>
<target dev='vdb' bus='virtio'/>
<alias name='virtio-disk1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
When the VM starts, it says:
2015-05-12 12:12:40,394 - util.py[WARNING]: Getting data from <class 'cloudinit.sources.DataSourceNoCloud.DataSourceNoCloudNet'> failed
* Stopping Read required files in advance (for other mountpoints) [ OK ]
* Stopping Read required files in advance (for other mountpoints) [ OK ]
* Stopping Read required files in advance (for other mountpoints) [ OK ]
2015-05-12 12:12:48,808 - url_helper.py[WARNING]: Calling 'http://169.254.169.254/2009-04-04/meta-data/instance-id' failed [3/120s]: request error [HTTPConnectionPool(host='169.254.169.254', port=80): Max retries exceeded with url: /2009-04-04/meta-data/instance-id (Caused by <class 'socket.error'>: [Errno 113] No route to host)]
Any suggestions on how to make it work?