Skip to content

Instantly share code, notes, and snippets.

@trstringer
Last active February 22, 2021 00:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trstringer/be871f87efca0cd41e7017db0fd31798 to your computer and use it in GitHub Desktop.
Save trstringer/be871f87efca0cd41e7017db0fd31798 to your computer and use it in GitHub Desktop.
cloud-init vendordata overwritten explanation

I’m running into an interesting issue while trying to specify both vendordata and userdata. From the documentation, userdata will overwrite vendordata unless userdata is in cloud-config-jsonp format. But my testing is showing that even in this case, vendordata is still being overwritten. Please see below for findings. Am I missing something? Thanks in advance!

The documentation states: "if both vendor and user have provided ‘runcmd’ then the default merge handler will cause the user’s runcmd to override the one provided by the vendor. To append to ‘runcmd’, the user could better provide multipart input with a cloud-config-jsonp part"

Vendor data

#cloud-config
runcmd:
  - echo hello from vendor data > /run/hello-world-vendordata

User data

#cloud-config-jsonp
[{ "op": "add", "path": "/runcmd", "value": ["echo hello jsonp > /run/hello_from_jsonp"] }]

Deployment1 (Vendor data only)

Post deployment "$ ls -la /run/hello*":

-rw-r--r-- 1 root root 23 Jul 29 19:11 /run/hello-world-vendordata

Works as expected.

Deployment2 (Vendor data with user data)

Post deployment "$ ls -la /run/hello*":

-rw-r--r-- 1 root root 12 Jul 29 19:08 /run/hello_from_jsonp

Unexpected. As per the documentation, if the userdata provided is in cloud-config-jsonp format then the vendordata should not be overwritten. The vendor data in fact did make it to the machine, but it was not run: "$ sudo cat /var/lib/cloud/instance/vendor-data.txt":

#cloud-config
runcmd:
  - echo hello from vendor data > /run/hello-world-vendordata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment