diff options
author | Chad Smith <chad.smith@canonical.com> | 2020-03-10 08:22:22 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-10 10:22:22 -0400 |
commit | 71af48df3514ca831c90b77dc71ba0a121dec401 (patch) | |
tree | a8fb89da80df6b119bffeb66ad162c6192f37803 /cloudinit/util.py | |
parent | 1f860e5ac7ebb5b809c72d8703a0b7cb3e84ccd0 (diff) | |
download | vyos-cloud-init-71af48df3514ca831c90b77dc71ba0a121dec401.tar.gz vyos-cloud-init-71af48df3514ca831c90b77dc71ba0a121dec401.zip |
instance-data: add cloud-init merged_cfg and sys_info keys to json (#214)
Cloud-config userdata provided as jinja templates are now distro,
platform and merged cloud config aware. The cloud-init query command
will also surface this config data.
Now users can selectively render portions of cloud-config based on:
* distro name, version, release
* python version
* merged cloud config values
* machine platform
* kernel
To support template handling of this config, add new top-level
keys to /run/cloud-init/instance-data.json.
The new 'merged_cfg' key represents merged cloud config from
/etc/cloud/cloud.cfg and /etc/cloud/cloud.cfg.d/*.
The new 'sys_info' key which captures distro and platform
info from cloudinit.util.system_info.
Cloud config userdata templates can render conditional content
based on these additional environmental checks such as the following
simple example:
```
## template: jinja
#cloud-config
runcmd:
{% if distro == 'opensuse' %}
- sh /custom-setup-sles
{% elif distro == 'centos' %}
- sh /custom-setup-centos
{% elif distro == 'debian' %}
- sh /custom-setup-debian
{% endif %}
```
To see all values: sudo cloud-init query --all
Any keys added to the standardized v1 keys are guaranteed to not
change or drop on future released of cloud-init. 'v1' keys will be retained
for backward-compatibility even if a new standardized 'v2' set of keys
are introduced
The following standardized v1 keys are added:
* distro, distro_release, distro_version, kernel_version, machine,
python_version, system_platform, variant
LP: #1865969
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index c02b3d9a..132f6051 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -656,7 +656,7 @@ def system_info(): 'system': platform.system(), 'release': platform.release(), 'python': platform.python_version(), - 'uname': platform.uname(), + 'uname': list(platform.uname()), 'dist': get_linux_distro() } system = info['system'].lower() |