I am probably missing something important, but I have troubles configuring contextualization for Fedora and CentOS. The documentation states that CentOS is expected to work correctly:
CentOS
Works correctly for cloud-init >= 0.7.4.
but this is definitely not my case.
For Fedora 23 (cloud-init-0.7.6-5.20140218bzr1060) I had to disable NetworkManager and use the static /etc/init.d/network-based configuration (I am OK with it), but there are still problems: firstly, cloud-init-local.service is run in parallel with /etc/init.d/network, which means that network initialization is often finished before the contextualization image is even read: 1311655 – cloud-init under OpenNebula works only after reboot. With some systemd magic described in the abovementioned bugzilla, it sets up networking correctly, but adds ssh keys to newly created “fedora” user only instead of root. Using cloud-init also adds about 20-25 seconds to the OS boot time. After that, the following warning is printed:
util.py[WARNING]: Getting data from <class 'cloudinit.sources.DataSourceOpenNebula.DataSourceOpenNebula'> failed
For CentOS 7 (cloud-init-0.7.5-6.el7) the situation is even worse. The cloud-init-local finishes, but cloud-init does not, and spills the following messages to the console:
url_helper.py[WARNING]: Calling 'http://169.254.169.254/2009-04-04/meta-data/instance-id' failed [-3059/120s]: request error [('Connection aborted.', error(113, 'No route to host'))]
It looks like it thinks it is running under EC2. It sets up networking correctly (again, after modifying the dependencies in cloud-init-local.service and after disabling NetworkManager and using /etc/init.d/network instead), but then waits forever. Only after “systemctl stop cloud-init.service”, the .ssh/authorized_keys files are populated, again allowing access to the “fedora” user, not root.
I have also tried to remove the .ssh/authorized_keys file and reboot the VM, but after the reboot, it does not get recreated.
The documentation mentions that the contextualization file starts with #cloud-config. This is not the case for me - my context.sh looks like this:
cat /mnt/context.sh
# Context variables generated by OpenNebula
DISK_ID='1'
ETH0_DNS='dns1 dns2'
ETH0_GATEWAY='my-gw'
ETH0_GATEWAY6='my_gw6'
ETH0_IP='my_ip'
ETH0_IP6='my_ip6'
ETH0_MAC='02:f1:2b:c0:00:04'
ETH0_MASK='255.255.255.0'
ETH0_NETWORK='my_netaddr'
NETWORK='YES'
SSH_PUBLIC_KEY='ssh-rsa AA...nw== me@myhost1
ssh-rsa AA...KQ== me@myhost2
'
TARGET='hda'
Is there any comprehensive HOWTO on using cloud-init with OpenNebula and Fedora or CentOS VMs? Thanks!