Revision history [back]

click to hide/show revision 1
initial version

For the user-data script to have any affect on your instance, the image you are booting needs to have tooling installed to fetch and execute that image. For most major distributions (CentOS, Red Hat, Fedora, Ubuntu, etc), this is cloud-init, and is installed on the cloud images for these distributions.

Cirros uses an alternative mechanism, which means that you probably don't want to use it for testing because it will not support the same sort of user-data scripts that larger distributions will support (for example, python isn't available on the cirros image, so you wouldn't be able to test out a python script in any case).

Your simple test ought to work. There are a number of diagnostic steps you can perform to figure out what went awry...

First, check if the metadata service is available. After logging into the cirros instance, try running:

# curl http://169.254.169.254/

This should return:

1.0
2007-01-19
2007-03-01
2007-08-29
2007-10-10
2007-12-15
2008-02-01
2008-09-01
2009-04-04

If you get an error response, this suggests that there are probably configuration issues in your openstack environment.

If the above worked, trying fetching the user-data script by running:

# curl http://169.254.169.254/latest/user-data

This should return your user-data script, e.g:

#!/bin/bash
echo "Hello World" > /tmp/test.txt

If that worked, see if the cirros tooling fetched it correctly. Run:

# cirros-query get user-data

This should return the same thing.

I suspect that one of the above steps will produce some useful diagnostic information. If you do see any errors, feel free to update your question with the additional information and we'll see if we can get things working.