Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run a cloud-init environment without using openstack or EC2?

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?

like image 331
garciadeblas Avatar asked May 08 '15 13:05

garciadeblas


People also ask

Where does cloud-init run?

The main directory containing the cloud-init specific subdirectories. It is typically located at /var/lib but there are certain configuration scenarios where this can be altered.

What is cloud-init and when would you use it?

Cloud-init is a service used for customizing Linux-based operating systems in the cloud. It allows you to customize virtual machines provided by a cloud vendor by modifying the generic OS configuration on boot.

Does cloud-init only run once?

By default, user data scripts and cloud-init directives run only during the first boot cycle when an EC2 instance is launched.


1 Answers

Is it possible to replicate a sort of cloud-init setup in a non-openstack environment?

Sure.

Cloud-init does not require a network metadata service (like that provided by EC2 and OpenStack) in order to operate. It will happily read configuration information from a local CD-ROM device; see, for example, the "Loggin in to your Atomic machine" section of this document, which described how to create the necessary filesystem.

This is documented here in the cloud-init documentation.

like image 115
larsks Avatar answered Sep 30 '22 03:09

larsks