New Question
0

How do I use Cloudbase-Init instance data?

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

cfkwok gravatar image

Cloud-Init equivalent would be this: https://cloudinit.readthedocs.io/en/l...

It seems like Cloudbase-Init also has it as of 1.1.0, based on this merge https://opendev.org/x/cloudbase-init/...

However, I am unable to get this working when trying to do a simple runcmd to echo {{ ds.meta_data.meta.name }}, 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
0

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

avladu gravatar image

Hello,

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:

https://github.com/cloudbase/cloudbas...

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

Thank you,
Adrian Vladu

edit flag offensive delete link more

Comments

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 +0300 )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 +0300 )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 +0300 )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

Stats

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

Seen: 1,067 times

Last updated: Dec 07 '20