Merging multiple user-data
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Expired
|
Undecided
|
Unassigned |
Bug Description
Provider : Terraform / LXD
ci-user-global.tf
locals {
cloud-
#cloud-config
packages:
- nginx
write_files:
- encoding: b64
content: |
${filebase6
path: /etc/fichierdeconf
owner: root:root
permissions: '755'
merge_how:
- name: list
settings: [append, recurse_list]
- name: dict
settings: [no_replace, recurse_dict]
- name: str
settings: [append, recurse_str]
EOF
}
ci-user-specific.tf
locals {
cloud-
#cloud-config
write_files:
- encoding: b64
content: |
${filebase6
path: /etc/fichierdeconf2
owner: root:root
permissions: '755'
merge_how:
- name: list
settings: [append, recurse_list]
- name: dict
settings: [no_replace, recurse_dict]
- name: str
settings: [append, recurse_str]
EOF
}
The first is specified on profile file, the last is specified on container file.
Only the last is applied even if merge_how is used.
Already seen a couple of similar issues and documentation but never saw how to fix, apply it correctly for cloud-init to merge theses two user-data files ?
information type: | Public → Public Security |
information type: | Public Security → Public |
Cloud-init has no knowledge of terraform; rather terraform incorporates cloud-init. In that sense, it doesn't make sense to expect cloud-init understand the abstractions you're using within terraform.
You mentioned a profile and a container specification. Does the profile file specify how to setup the instance, whereas the container file sets up the container? If so, then the profile config is being passed to the cloud-init running on the instance, and the container config will be passed to cloud-init on the container. If that's not how things are setup, can you help me understand what exactly these two configs are being applied to? Where is the first being defined such that parts need to be overridden by the second?
The sort of merging you're asking about is really only applicable in cases where you're sending userdata as a list of include files or as a multipart MIME file. /cloudinit. readthedocs. io/en/latest/ topics/ format. html#include- file /cloudinit. readthedocs. io/en/latest/ topics/ format. html#helper- subcommand- to-generate- mime-messages
https:/
and
https:/
E.g., you can have userdata that pulls in multiple cloud-configs and merges them accordingly: /raw.githubuser content. com/canonical/ cloud-init/ 403f70b930e3ce0 f05b9b6f0e1a38d 383d058b53/ doc/examples/ cloud-config- run-cmds. txt /raw.githubuser content. com/canonical/ cloud-init/ 403f70b930e3ce0 f05b9b6f0e1a38d 383d058b53/ doc/examples/ cloud-config- boot-cmds. txt
"""
#include
https:/
https:/
"""