This article refers to a SUSE OpenStack Cloud 5 environment. Both, admin and control node run with SLES11 as does one of the two compute nodes, the other compute node runs with SLES12.
I’ve had my share trying to provide user-data to my instances, regardless if I used config-drive or the meta-data service.
There are just a few things you should consider if you want to configure your instances after they have been created.
You have to ensure that the image you want to use has the cloud-init package installed. Also make sure that the respective services are running. In SLES11 you can check that by running:
host-192-168-123-159:~ # chkconfig -l cloud-config 0:off 1:off 2:on 3:on 4:off 5:on 6:off cloud-final 0:off 1:off 2:on 3:on 4:off 5:on 6:off cloud-init 0:off 1:off 2:on 3:on 4:off 5:on 6:off cloud-init-local 0:off 1:off 2:on 3:on 4:off 5:on 6:off
That would be enough to be able to provide user-data via config-drive, usually that information is accessible via the meta-data service. If the meta-data service is not accessible for the instance, config-drive can be a alternative.
When using config-drive to provide user-data to the instance OpenStack writes that data to a special configuration drive which is attached to the instance when it boots. The instance can mount that drive and read the information. That drive is unmounted after user-data have been applied. You can find more details in the End-User-Guide.
If you don’t want to use the config-drive but inject user-data directly via the meta-data service, you have to ensure that the image has no route for the CIDR 169.254.0.0/16, otherwise the meta-data service will be unreachable. To check that you can execute
host-192-168-123-192:~ # netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 192.168.123.1 0.0.0.0 UG 0 0 0 eth0 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0 192.168.123.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
If this route exists you’ll probably get an error trying to reach the meta-data service:
host-192-168-123-192:~ # curl http://169.254.169.254:80/latest curl: (7) couldn't connect to host
To make the meta-data accessible delete the route:
host-192-168-123-192:~ # route del -net 169.254.0.0/16 host-192-168-123-192:~ # route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.123.1 0.0.0.0 UG 0 0 0 eth0 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 192.168.123.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
Make that change permanent so that this route won’t appear after a reboot. Now you should be able to access the meta-data service:
host-192-168-123-192:~ # curl http://169.254.169.254:80/latest/meta-data ami-id ami-launch-index ami-manifest-path block-device-mapping/ hostname instance-action instance-id instance-type kernel-id local-hostname local-ipv4 placement/ public-hostname public-ipv4 ramdisk-id reservation-id security-groups
You can find more information about meta-data in the OpenStack Docs.
Now you can create a snapshot from that instance and upload it as a new image into the cloud. All instances you launch from that image can now be configured during creation time via user-data.