cloud-init verification or logs?
-
I am using cloud-init to run some startup scripts for my instances in terraform. What is really annoying is that if one line on your cloud-init script is incorrect, the script doesn't run at all. I had to manually remove lines one by one to find suspect lines. As I create more cloud-init scripts, I run into more issues.
An alternative would be calling
cloud-init
to run a bash script, but I have had issues getting this to work in v12. It works fine in v11. Cloud-init is generally cross platform which is an advantage. You can essentially use the same script with any flavor of linux including Ubuntu, CentOS and Amazon. So I would like to figure out how to better troubleshoot and writecloud-init
scripts.Although getting bash scripts working properly in v12 would be nice. All the examples I am seeing are in v11 and they dont seem to work in v12.
-
They should be in journalctl right?
So I don't have a ton of experience with the AWS side, but with GCP you define your startup scripts like this:
Here's what's in my script:
#!/bin/bash sudo touch /etc/the_file sudo echo "is this working?" >> /etc/the_file cat /etc/this-file-doesnt-exist
Then after boot, you can run
jouranlctl --boot
and it gives you logs since last boot. -
Hoping to do some more testing this week and updated you @stacksofplates
-
So I checked
journalctl --boot
which has a very large output. However I did find some helpful information aboutcloud-init
. I got to see what Amazon does in their portion of the script, and I got to see when packages were installed from mycloud-init
. However other commands such assed
orecho
did not show up anywhere. Although I can confirm them being run.This kind of helps, but it isn't 100% what I want.
-
@IRJ said in cloud-init verification or logs?:
So I checked
journalctl --boot
which has a very large output. However I did find some helpful information aboutcloud-init
. I got to see what Amazon does in their portion of the script, and I got to see when packages were installed from mycloud-init
. However other commands such assed
orecho
did not show up anywhere. Although I can confirm them being run.This kind of helps, but it isn't 100% what I want.
Ah ok. That's interesting that they don't show up. It might just be stderr for the script portion then? Idk.