Armand Grillet
Armand Grillet

Reputation: 3399

Unable to write a file using a cloud config on Amazon EC2

I am trying to write a file when starting an EC2 instance running on a simple Centos 7 AMI using some user data. However, I am not able to do it when I use a specific path and I do not know why. Here is a cloud config that works (the dcos folder and the mesos-slave-common are created):

#cloud-config
  "write_files":
    - "content": |
        MESOS_CGROUPS_LIMIT_SWAP=true
      "owner": |-
        root
      "path": |-
        /etc/lib/dcos/mesos-slave-common
      "permissions": |-
        0644

Here is the one that does not work (the file is not created but the dcos folder is):

#cloud-config
  "write_files":
    - "content": |
        MESOS_CGROUPS_LIMIT_SWAP=true
      "owner": |-
        root
      "path": |-
        /var/lib/dcos/mesos-slave-common
      "permissions": |-
        0644

The only difference between the two is /etc is /var in the second snipped but in both cases the dcos folder does not exist on the raw AMI. The issue I see when printing /var/log/cloud-init-output.log on the second instance is 2017-03-09 16:49:03,702 - util.py[WARNING]: Running write-files (<module 'cloudinit.config.cc_write_files' from '/usr/lib/python2.7/site-packages/cloudinit/config/cc_write_files.pyc'>) failed.

Does anyone know where is the issue from and how to fix it?

Upvotes: 1

Views: 4374

Answers (1)

Rafael Fonseca
Rafael Fonseca

Reputation: 160

A bit late to answer this, but the file to look in for the actual error that triggered that on an Ubuntu 16.04 instance is: /var/log/cloud-init.log.

Bear in mind this file is very verbose. The actual error message is likely to be closer to the bottom of it. Search for a Python stack trace.

Upvotes: 4

Related Questions