The closest I've seen to configurable variables is [Instance Metadata].(https://cloudinit.readthedocs.io/en/latest/topics/instancedata.html#)
It says you can use:
- userdata provided at instance creation
You can use data created in /run/cloud-init/instance-data.json
.
You can use import this instance data using Jinja templates in your YAML cloud-config to pull in this data:
## template: jinja
#cloud-config
runcmd:
- echo 'EC2 public hostname allocated to instance: {{
ds.meta_data.public_hostname }}' > /tmp/instance_metadata
- echo 'EC2 availability zone: {{ v1.availability_zone }}' >>
/tmp/instance_metadata
- curl -X POST -d '{"hostname": "{{ds.meta_data.public_hostname }}",
"availability-zone": "{{ v1.availability_zone }}"}'
https://example.com
But I'm not exactly sure how you create the /run/cloud-init/instance-data.json
file.
This CoreOS issue suggests that if you put variables into /etc/environment
then you can use those.
I know for example that there are a few variables used such as $MIRROR
$RELEASE
, $INSTANCE_ID
for the phone_home module.
cloud-init
populates the/run/cloud-init/instance-data.json
file in order to unify the data provided from the various cloud providers. Thev1
entries are the safest to use, since they are where cloud-init collects common data, and the keys are guaranteed to exist. – Rist