https://pulumi.com logo
#python
Title
# python
s

some-notebook-86727

02/13/2024, 1:08 PM
Hello. I'm trying to add a cloud-init configuration as a file to be transferred to a proxmox host. Proxmox doesn't allow for the cloudinit config to be sent over the API, so I need to first create a file on a certain path (I'm not worried about transferring it to ssh or anything like that). Could anyone help me to understand how I could do this? This is what I've tried this far:
Copy code
ci_config = cloudinit.get_config(base64_encode=False,
    gzip=False,
    parts=[cloudinit.ConfigPartArgs(
        content_type="text/x-shellscript",
        content="baz",
        filename="script.sh"
    )])

def write_to_file(contents):
    with open("cloud-init.cfg", "w") as f:
        f.write(contents)

ci_config.apply(write_to_file)
But I get:
Copy code
pulumi:pulumi:Stack (proxmox-main):
    error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      File "/root/work/ioc/pulumi/__main__.py", line 31, in <module>
        ci_config.apply(write_to_file)
        ^^^^^^^^^^^^^^^
    AttributeError: 'AwaitableGetConfigResult' object has no attribute 'apply'
I've also tried
ci_config.rendered.apply(write_to_file)
with similar results.
Ok, I think I've got it. using
print(ci_config.rendered)
as such actually works. Heh 🙂
4 Views