/srv/irclogs.ubuntu.com/2021/12/05/#cloud-init.txt

fr3fouhello13:47
fr3fouI'm trying to use cloud-init on Linode which unfortunately, doesn't have support for cloud-init, so I have to do some magic using their "StackScript" thing. I copied this script from GitHub but I think something is wrong because it doesn't seem to be running my cloud config. Can anyone take a look?13:49
fr3fouhttps://gist.github.com/fr3fou/1d559364c08fcd274b9a33da44dbc57a13:49
minimalfr3fou: as Linode do not support cloud-init directly I never saw the point of wrapping cloud-init inside StackScript rather than just using StackScript only13:50
fr3fouI don't want to rewrite my cloud-init script which is in yaml :/13:51
fr3fouone thing I couldn't find in the docs for cloud-init - where am I supposed to place my config files? i.e the "userdata"13:51
fr3fouone thing I couldn't find in the docs for cloud-init - where am I supposed to place my config files? i.e the "userdata". The script I sent places it in `/var/lib/cloud/seed/nocloud-net/user-data`13:52
minimaldon't you provide this when you create the VM in Linode?13:53
minimalso, for example, if using the linode-cli command you use "--stackscript_data" option13:55
fr3fouyeah, I provide the cloud-config as a base64 encoded yaml file which then the script decodes and places it in the path I sent above13:55
fr3fouthe file is there, I can cat it13:55
fr3foubut it doesn't seem to have run13:55
minimalok, so did you look at /var/log/cloud-init.log to see what happened?13:56
fr3fouyeah, can't seem to find logs related to my config13:56
minimalyou may want to enable debugging to get more information in that logfile13:56
fr3fouI'll do that in a bit13:58
fr3foumeanwhile, is that the correct directory to place the user-data?13:58
minimalI think so, however I've never put config there myself14:01
minimalyou can increase logging/debug by changing the file /etc/cloud/cloud.cfg.d/05_logging.cfg14:02
minimalchange the references of "INFO" to "DEBUG"14:02
fr3fouthere are no "INFO" references14:03
fr3fouthey are all set to DEBUG14:03
fr3fouthey are all set to "DEBUG"14:03
minimalok, so there should be a lot of details in /var/log/cloud-int.log14:04
fr3fouhttp://0x0.st/-h6D.log14:05
fr3fouhere's the full log14:05
minimaldoes the file /var/lib/cloud/instance/user-data.txt contain the user-data you provided?14:11
fr3foujust saw that log line, nope14:12
fr3fouroot@localhost:~# cat /var/lib/cloud/instances/nocloud/user-data.txt14:12
fr3fou#!/bin/bash14:12
fr3fourm -rf -- /var/lib/cloud/seed/nocloud14:12
fr3fouroot@localhost:~# cat /var/lib/cloud/instances/nocloud/user-data.txt.i14:12
fr3fouContent-Type: multipart/mixed; boundary="===============1521525572937868930=="14:12
fr3fouMIME-Version: 1.014:12
fr3fouNumber-Attachments: 114:12
fr3fouroot@localhost:~# cat /var/lib/cloud/instances/nocloud/user-data.txt14:12
fr3fou```14:12
fr3fou#!/bin/bash14:12
fr3fourm -rf -- /var/lib/cloud/seed/nocloud14:12
fr3fouroot@localhost:~# cat /var/lib/cloud/instances/nocloud/user-data.txt.i14:12
fr3fouContent-Type: multipart/mixed; boundary="===============1521525572937868930=="14:12
fr3fouMIME-Version: 1.014:12
fr3fouNumber-Attachments: 114:12
fr3fou```14:12
minimalso try changing the FILE_USERDATA and FILE_METADATA values to use "nocloud" instead of "nocloud-net" perhaps? where did you get that script from?14:14
fr3fouhttps://github.com/displague/terraform-linode-cloudinit-example/blob/master/stackscript.sh14:15
fr3fouchanged it, will test it rn14:18
minimaljust wondering where the "rm -rf -- /var/lib/cloud/seed/nocloud" is coming from14:20
fr3fousam14:21
fr3fousame14:21
fr3fouroot@localhost:~# cat /var/lib/cloud/instances/nocloud/user-data.txt14:23
fr3fou#!/bin/bash14:23
fr3fourm -rf -- /var/lib/cloud/seed/nocloud14:23
fr3fousitll the same content wtf14:23
minimalso you have the init.tpl file with the user-data contents that you want to use?14:28
fr3fouit's slightly different in my code14:30
fr3fou  stackscript_id   = linode_stackscript.cloud-init.id14:30
fr3fou  stackscript_data = {14:30
fr3fou    "userdata" = base64encode(templatefile("cloud-init/setup.tmpl.yaml", {14:30
fr3fou      ip_whitelist_string = join(" ", var.ip_whitelist)14:30
fr3fou      domain              = var.root_domain14:30
fr3fou      default_ssh_key     = var.default_ssh_key14:30
fr3fou    }))14:30
fr3fou  }14:30
fr3fouhere's my terraform config14:30
fr3foumy file is there though14:32
minimalnot sure what is going on. Have you tried testing the original Terraform including the original user-data?14:36
minimalif that works then it would point to your changes introducing problems14:37
minimalif the original does not work however then that's a different situation14:37
fr3foulemme see14:38
minimalfor example the original had stackscript_id  = "${linode_stackscript.cloudinit_stackscript.id}", which is clearly assigning a variable value14:39
minimalwhereas your code has stackscript_id   = linode_stackscript.cloud-init.id14:39
fr3fouthat's just old terraform syntax14:39
fr3fouit's the same thing14:39
fr3fouthe way the original one uses the template resource is also deprecated14:40
minimalno "${}". I'm not saying that is the issue, just that its a difference. Yes I realise terraform syntax has changed over time, I haven't kept up with the changes :-)14:40
fr3foumy IDE tells me I can remove the "${}" when wrapping it with "${}"14:41
minimalanyway I'd recommend trying to get the original stuff working (with any revisions necessary for recent Terraform changes) before introducing your own changes.14:42
fr3fousure14:46
fr3founope, doesn't seem to work14:57
minimalis it behaving the same? the same user-data contents visible in /var/lib/cloud/instance/user-data?14:58
fr3foucat /var/lib/cloud/instances/nocloud/user-data.txt14:58
fr3fou#!/bin/bash14:58
fr3fourm -rf -- /var/lib/cloud/seed/nocloud14:58
fr3fouyeah14:58
minimalfr3fou: how do you view a stackscript?15:03
fr3fouwhere? on linode?15:04
minimalyes, trying to see the actual contents of the stackscript that terraform is using15:05
fr3fouhttps://i.imgur.com/1Bj4vqf.png15:06
minimalthough the original author's stackscript was a "community" script that would be viewable in some way without a Lindone account (just to verify its contents make the github repo's contents), I guess not15:08
fr3fouthing is, I'm not using the author's stackscript15:09
fr3fouI just copy pasted it in my own repo and uploaded my own which has the same contents15:09
minimalok. I don't see that "rm -rf" anywhere in the author's repo15:17
fr3fouyeah, I'm super confused as well15:24
fr3fouI think I'll just rewrite my cloud-config to a shellscript..15:25
fr3fouthanks a lot for your time ^^15:25
minimalI'm interested in figuring out why its not working as I build Alpine Linux cloud-init images intended for various cloud providers, I just haven't gotten around to looking at Linode so far as the whole StackScript thing made it awkward15:30
fr3foudid I miss something? had to leave for a bit15:42
minimalnope, its quiet on here today15:43
fr3foudoes the entire runcmd block continue if the previous command failed?15:56
fr3foucan anyone help me translate this block to shell commands?16:30
fr3fouusers:16:30
fr3fou  - name: push16:30
fr3fou    groups:16:30
fr3fou      - docker16:30
fr3fou    lock_passwd: true16:30
fr3fou    shell: /bin/bash16:30
fr3fou    ssh-authorized-keys:16:30
fr3fou      - ${default_ssh_key}16:30
fr3fou    sudo:16:30
fr3fou      - ALL=(ALL) NOPASSWD:ALL16:30
fr3foucan't figure out the sudo flags16:30
minimalfr3fou: with debugging on you should see the resultant shell commands in /var/log/cloud-init.log17:28
minimalfr3fou: for sudo in user-data I typically use "sudo: ["ALL=(ALL) NOPASSWD:ALL"]"17:29
minimalhowever having it the way you do should also work *if* you add quotes around it17:30
minimali.e. - "ALL=(ALL) NOPASSWD:ALL"17:30
fr3fouthat cloud config has worked on my DO droplet for 1 month17:30
fr3fou🤷‍♂️17:30
minimalok, quotes might not be *required* but I use them myself17:39
minimalanyway as I pointed out the logs, with debug, show the shell command run17:39
minimalit won't show the sudo stuff though as that's written by Python, not shell, to the sudoers file17:40
fr3fouis it a good or bad idea to have nopasswd though?17:51
minimalyou mean locked password?17:52
fr3fouI mean not requiring the password when trying to sudo17:52
minimalpersonally I have sshd set for keys only and "lock_passwd: True" for the default user17:53
minimalso "ssh_pwauth: False" in /etc/cloud/cloud.cfg17:54
fr3fouright okay17:54
minimalalso best to set "disable_root: True" in the same file to prevent root login via SSH17:59
fr3fouyeah, I have that18:00

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!