0

I used to have

user_data  = data.template_file.user_data.rendered

I changed that to,

user_data  = data.template_cloudinit_config.master.rendered

And I added,

data "template_cloudinit_config" "master" {
  gzip          = true
  base64_encode = true

  # get common user_data
  part {
    filename     = "cloud-init.cfg"
    content_type = "text/part-handler"
    content      = data.template_file.user_data.rendered
  }
}

But now I'm getting this error, in my cloud-init.log

2022-07-12 15:19:21,514 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/1a6e9475-5d46-4b3f-b7bc-642055614e22/handlers/part-handler-000.py - wb: [600] 16701 bytes
2022-07-12 15:19:21,514 - util.py[WARNING]: Failed at registering python file: /var/lib/cloud/instances/1a6e9475-5d46-4b3f-b7bc-642055614e22/handlers/part-handler-000.py (part handler 0)
2022-07-12 15:19:21,514 - util.py[DEBUG]: Failed at registering python file: /var/lib/cloud/instances/1a6e9475-5d46-4b3f-b7bc-642055614e22/handlers/part-handler-000.py (part handler 0)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/cloudinit/handlers/__init__.py", line 144, in walker_handle_handler
    mod = fixup_handler(importer.import_module(modname))
  File "/usr/lib/python3/dist-packages/cloudinit/importer.py", line 15, in import_module
    __import__(module_name)
  File "/var/lib/cloud/instances/1a6e9475-5d46-4b3f-b7bc-642055614e22/handlers/part-handler-000.py", line 3
    users:
         ^
SyntaxError: invalid syntax

However, nothing changed in that file. What's going on?

1 Answer 1

0

The problem here was I had

content_type = "text/part-handler"

I should have had,

content_type = "text/cloud-config"

For more information:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.