This message was deleted.
# getting-started
s
This message was deleted.
1
l
content
has to be the actual content.
filename
is just a string that is put into the MIME part header.
That code will create a script called "cloudinit/test.yaml" on your target system, containing "baz".
I use cloudinit via typescript, so there may be differences, but: you probably want to use the get_config function, the Config resource is deprecated; and you need to use
rendered
on the object returned from get_config, in order to get the rendered JSON object of the MIME parts.
f
@little-cartoon-10569 awesome, thank you 🙏 this helped a lot as I was totally confused by content and filename. I adjusted my file accordingly and now have it got working :)
Copy code
# read cloud-init config payload from file
with open(cloud_init_path) as f:
  init_payload = f.read()

# create cloud-init config  
foo = cloudinit.get_config(base64_encode=False,
                                    gzip=False,
                                    parts=[cloudinit.GetConfigPartArgs(
                                        content=init_payload,
                                        content_type="text/cloud-config",
                                        filename="init.cfg",
                                    )])

node0 = hcloud.Server(
  get_name('node'),
  image=image,
  location=location,
  server_type=server_type,
  ssh_keys=[default_ssh.id],
  user_data=foo.rendered # set cloudinit config
)
👍 1
111 Views