New Question

How do I use Cloudbase-Init instance data?

asked 2020-12-04 22:49:15 +0200

cfkwok gravatar image

Cloud-Init equivalent would be this:

It seems like Cloudbase-Init also has it as of 1.1.0, based on this merge

However, I am unable to get this working when trying to do a simple runcmd to echo {{ }}, it cannot find meta.

Could it be that it's not reading in the metadata? Where can I locate the instance-data file for Windows?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2020-12-07 15:56:32 +0200

avladu gravatar image


Currently, only the following V1 standard keys are supported in cloudbase-init which have the same implementation as in cloud-init:

Those values can be addressed in the following way: {{ v1.instance_id }} .

Using the v1 namespace keys will guarantee that the cloud-config scripts can be reused by both cloud-init and cloudbase-init.

There is a ds equivalent for backward compatibility with some older implementation in cloud-init, that contains the same v1 keys + the 'hostname' key (hostname = local_hostname).

If you want to use ds.metadata namespace to get the hostname, use: {{ ds.metadata.localhostname }} or {{ ds.metadata.hostname }} . The use of ds.meta_data namespace is not recommended, as those keys depend on the metadata provider and can be different across implementations (OpenStack versus OpenNebula or Google Cloud).

More information here:

I will add the documentation in cloudbase-init readthedocs shortly.

Thank you,
Adrian Vladu

edit flag offensive delete link more


Awesome, thanks Adrian! I was able to get values from both echo "{{ v1.local_hostname }}" and echo "{{ ds.meta_data.local_hostname }}"

cfkwok gravatar imagecfkwok ( 2020-12-07 17:36:50 +0200 )edit

However, I am trying to inject values from Openstack, but it might be an issue with reading the metdata file. Is there a /run/cloud-init/instance-data.json equivalent? I'd like to see all the available parameters and values in v1 and ds.

cfkwok gravatar imagecfkwok ( 2020-12-07 17:38:07 +0200 )edit

In v1 namespace you have the following: { "instance_id": instance_id, "local_hostname": hostname, "public_ssh_keys": self.get_public_keys() }

avladu gravatar imageavladu ( 2020-12-14 12:07:51 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-12-04 22:49:15 +0200

Seen: 107 times

Last updated: Dec 07 '20