Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud-init validator

Tags:

cloud-init

Wondering if anyone knows of a validator that can validate cloud-init config similar to this. We tried it and it gives a bunch of errors that are not applicable e.g., it does not recognize package_update which is a standard keyword that can be found here in the official documentation for example. So we are looking for a validator that works and recognizes the keywords in the official documentation.

enter image description here

like image 706
morpheus Avatar asked Jan 29 '19 18:01

morpheus


People also ask

How do I check my init cloud status?

You can check the /var/lib/cloud/data/status. json for cloud-init status. Or if the host is using upstart, add one init process in /etc/init/newprocess. conf and newprocess.

Where is cloud-init config file?

Cloud-init config is provided in two places: /etc/cloud/cloud. cfg. /etc/cloud/cloud.

Where does cloud-init look for user data?

So cloud-init will retrieve your user-data from an attached ISO image (from a file named user-data. txt ). When cloud-init runs, it will typically populate /var/lib/cloud-init/instance with any information retrieved from the cloud provider, so you should find a copy of the user data in that directory.


1 Answers

I hit this one recently too and found a nice way to do it.

In Ubuntu you can use the follwoing to validate the file parses correctly.

cloud-init devel schema --config-file bob.txt

This will give you the following notice if the files are valid or invalid

:~$ sudo cloud-init devel schema --config-file bob.txt
Valid cloud-config file bob.txt

$ nano bob.txt #edited the yaml to make it invalid
:~$ sudo cloud-init devel schema --config-file bob.txt
Cloud config schema errors: format-l2.c1: File bob.txt is not valid yaml. while parsing a block mapping
  in "<byte string>", line 2, column 1:
    package_upgrade: true
    ^
expected <block end>, but found '-'
  in "<byte string>", line 6, column 1:
    - 'curl -fsSL https://get.docker ... 
    ^

While your working with cloud init files cloud-init status --wait and many of the other commands on the cli are super useful.

Hmmm on further inspection it doesn't seem to catch many types of errors but the Cloud Init docs list it as a work in progress.

cloud-init devel schema: A #cloud-config format and schema validator. It accepts a cloud-config yaml file and annotates potential schema errors locally without the need for deployment. Schema validation is work in progress and supports a subset of cloud-config modules.

like image 175
lawrencegripper Avatar answered Jan 11 '23 23:01

lawrencegripper