<p>The problem here was I had</p>
<pre><code>content_type = &quot;text/part-handler&quot;
</code></pre>
<p>I should have had,</p>
<pre><code>content_type = &quot;text/cloud-config&quot;
</code></pre>
<hr />
<p>For more information:</p>
<ul>
<li><a href="https://cloudinit.readthedocs.io/en/latest/topics/format.html" rel="nofollow noreferrer">https://cloudinit.readthedocs.io/en/latest/topics/format.html</a></li>
</ul>

CC BY-SA 4.0
2022-07-12T16:10:54.017Z
2022-07-12T16:10:54.017Z
Evan Carroll
<p>I used to have</p>
<pre><code>user_data  = data.template_file.user_data.rendered
</code></pre>
<p>I changed that to,</p>
<pre><code>user_data  = data.template_cloudinit_config.master.rendered
</code></pre>
<p>And I added,</p>
<pre><code>data &quot;template_cloudinit_config&quot; &quot;master&quot; {
  gzip          = true
  base64_encode = true

  # get common user_data
  part {
    filename     = &quot;cloud-init.cfg&quot;
    content_type = &quot;text/part-handler&quot;
    content      = data.template_file.user_data.rendered
  }
}
</code></pre>
<p>But now I'm getting this error, in my <code>cloud-init.log</code></p>
<pre><code>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 &quot;/usr/lib/python3/dist-packages/cloudinit/handlers/__init__.py&quot;, line 144, in walker_handle_handler
    mod = fixup_handler(importer.import_module(modname))
  File &quot;/usr/lib/python3/dist-packages/cloudinit/importer.py&quot;, line 15, in import_module
    __import__(module_name)
  File &quot;/var/lib/cloud/instances/1a6e9475-5d46-4b3f-b7bc-642055614e22/handlers/part-handler-000.py&quot;, line 3
    users:
         ^
SyntaxError: invalid syntax
</code></pre>
<p>However, nothing changed in that file. What's going on?</p>

<terraform><cloud-init>
Switching to multi-part cloud-init, getting: SyntaxError: invalid syntax
Evan Carroll
# Switching to multi-part cloud-init, getting: SyntaxError: invalid syntax

(Asked by: username_0 on 2022-07-12)

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?

**Tags:** terraform, cloud-init


---

## 1 answers

### Answer by username_0 on 2022-07-12. Score: 0 | Accepted answer

The problem here was I had
content_type = "text/part-handler"

I should have had,
content_type = "text/cloud-config"


For more information:

https://cloudinit.readthedocs.io/en/latest/topics/format.html


---

