[14:13] Hello! I'm new to cloud-init and I am using this with an openstack set up, to run some commands (create a specific user, etc) after VM is created. I was wondering if there was a way to run Cloud-init on the same VM without rebooting it ? [14:48] never mind, I found it here: https://gist.github.com/maoueh/8662b8e0da0ccd99296a9a9a6b67dad0 === rharper` is now known as rharper [15:26] I'm trying to find a good pattern for using cloud-init to provision Raspberry Pi devices. [15:36] I found that the Raspbian repo had 0.7.9 and that lacked the more in depth NoCloud features. So, I figured out how to install from source. https://stackoverflow.com/a/48845732/117471 [15:42] So at this point I'm trying to use /var/lib/cloud/seed/nocloud-net/ because it is pretty easy to get some positive feedback. But, I'm struggling to get the solution I need. [15:42] I really have 2 goals: [15:44] 1. Have the `user-data` and `meta-data` files live on the volume labeled `boot` that is mounted at `/boot` [15:45] 2. Have a script (/boot/on_boot.sh) called on every boot if it exists. [15:46] That's it. But, I'm facing these challenges: [15:47] 1. /var/lib/cloud/scripts/per-boot seems to do nothing for me. [15:48] 2. Changes to `/boot/user-data` are not picked up by the `#include` directive in `/var/lib/cloud/seed/nocloud-net/user-data` [15:56] 3. The `meta-data` file does not seem to support `#include` so I'm stuck with whatever goes into `/var/lib/cloud/seed/nocloud-net/meta-data` [15:59] 4. Putting ` ds=nocloud[;seedfrom=/boot/;instance-id=raspberrypi]` at the end of `/boot/cmdline.txt` did not seem to make it locate `/boot/user-data` and `/boot/meta-data`. That is why I am using `/var/lib/cloud/seed/nocloud-net/`. [15:59] I think that covers it. [16:19] brunobro_: can you share your cloud-init.log ? /var/log/cloud-init*.log [16:22] sidx64: on cloud-init v 17.1 or later you can run "cloud-init clean --logs" instead of those rm -rf lines. Also it'd be worth checking your initially provisioned datasource name in /run/cloud-init/result.json. If it is a datasource with Local in the name you might have to run "cloud-init init --local" before "cloud-init init" [16:23] thankyou @blackboxsw [16:23] will tryu this [16:24] no prob: otherwise you risk using a cached local datasource which wouldn't update metadata (if your metadata has changed) [16:25] Oh okay! [16:25] Did not know that! [16:25] I actually have been changing the metadata [16:25] so this helps a lot! [16:25] thank you [16:26] brunobro_: you may want to instead label your volume 'cidata'; and cloud-init will find that volume and read it like the nocloud-net seed in /var/lib/cloud/seed/noncloud-net instead [17:02] rharper: I can't relabel the volume. It is the boot volume. I'm not going to try to convince the Raspbian distribution to change their volume name. But, there is supposed to be a way to tell cloud-init somewhere else to look. [17:02] brunobro_: ok [17:03] brunobro_: so, no wait to tell cloud-init to find a nocloud-net datasource somewhere else; but in the embedded seed, you should be able to refer to your volume for additional sources of user-data [17:03] s/wait/way [17:07] rharper: I added logs to https://gist.github.com/RichardBronosky/fa7d4db13bab3fbb8d9e0fff7ea88aa2 [17:08] thx [17:14] what can I do about per-boot? [17:23] brunobro_: looking at the logs; [17:36] brunobro_: from the logs, I think it's not finding your nocloud seed in /boot; it emits the "Using Fallback Datasource" which isn't going to run your user-data that was provided; [17:36] next to see why the seedfrom=/boot didn't work for you [17:36] I need to look at the cloud-init NoCloud source to see how it processes that [17:40] rharper: What should a "nocloud seed" in /boot look like? I never can get clear info on the directory structure expectations. [17:42] http://cloudinit.readthedocs.io/en/latest/topics/dir_layout.html says that "seed/" is TBD and "scripts/" is also pretty vague. [17:45] brunobro_: /boot/{meta-data,user-data} ; I think you've that part correct; [17:47] okay, good. I originally did /var/lib/cloud/seed/{meta-data,user-data} and that did not work. But I found a blog example that told me about nocloud-net [17:47] so, it's /var/lib/cloud/seed/nocloud-net/{user-data, meta-data} [17:48] and you may have something in there; the stacktrace looks like it was comparing the instance_id found in one of the two meta-data files, and they didn't match; [17:48] I do have both of those populated. [17:49] I've never tested having multiple locations and referencing them both [17:49] so I suspect we need to pick one location and getting your config working [17:52] I think if you remove /var/lib/cloud/seed/nocloud-net and then 'cloud-init clean' to remove any per-instance generated data from /var/lib/cloud and logs; and reboot; that should get things goign if your gist is accurate [17:52] I don't intend to have multiple. I'm experimenting. And not remembering what artifacts I've left around. [17:53] the seedfrom=/boot allows nocloud datasource to read that directory like it's a nocloud source; your files look fine w.r.t meta-data and user-data; [17:53] if that works, then we can move to getting your scripts to run; [17:53] I'm stepping out for lunch, but just let me know how it goes and I'll see what I can do to get your going [17:53] thanks! [19:40] rharper this is brunobro_ from earlier. (I didn't have a ZNC container running before.) [19:40] brunobronosky: hi [19:41] I'm updating that gist to make it more accurate. i will also purge the logs and start them fresh. I'll let update you shortly. But for now I'll lead with a question... [19:44] In the log I'm seeing "2018-02-20 18:05:39,432 - main.py[DEBUG]: No kernel command line url found." even though `cat /proc/cmdline` gives... [19:44] 8250.nr_uarts=0 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 dwc_otg.lpm_enable=0 console=ttyS0,115200 console=tty1 root=PARTUUID=3e8f7ed9-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait ds=nocloud[;seedfrom=/boot/;instance-id=iid-raspberrypi-nocloud] [19:45] brunobronosky: lemme look [19:45] that last KV pair is my interpretation of the docs http://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html [19:47] brunobronosky: I don't think that is related, the code is looking for 'cloud-config-url', 'url' keys in the kernel command line for [19:48] it's used in a read-only-root configuration with MAAS, a baremetal cloud product [19:49] brunobronosky: you should see something like [19:49] Looking for data source in: ['NoCloud', 'None'], via packages ['', 'cloudinit.sources'] that matches dependencies ['FILESYSTEM'] [19:49] 2018-02-15 16:23:32,828 - __init__.py[DEBUG]: Searching for local data source in: ['DataSourceNoCloud'] [19:49] 2018-02-15 16:23:32,828 - handlers.py[DEBUG]: start: init-local/search-NoCloud: searching for local data from DataSourceNoCloud [19:52] The use of "url" concerns me. Can it accept a local file path? (maybe with the file:// scheme?) [20:11] Okay rharper https://gist.github.com/RichardBronosky/fa7d4db13bab3fbb8d9e0fff7ea88aa2#file-cloud-init-log is current. [20:12] brunobronosky: thanks, reading [20:14] Also, I'm seeing https://github.com/cloud-init/cloud-init/blob/master/doc/sources/kernel-cmdline.txt is consistent with your description. Though, both you and smoser are inconsistent with my understanding of http://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html [20:17] I didn't want to trouble you with my lack of understanding when you said, "I don't think that is related" earlier. I think that is more important than I originally presumed. I guess my follow up should be "You don't think what is related to what?" [20:17] the message comes code looking for cloud-config-url, which is used separately from the NoCloud Datasource, [20:17] it's not related to the current failure [20:21] Got it. So, the part of the docs that I am hanging onto... Are they valid? Does that mean what I think it means? Inigo Montoya? [20:21] I think so, I'm looking at cloudinit/sources/DatasourcesNoCloud.py:parse_cmdline_data [20:21] to see what, if anything it doesn't like [20:24] I think the brackets [20:25] [ ] means the contents are optional [20:25] you can use: ds=nocloud or ds=nocloud;seedfrom=;instance-id=bar [20:25] adjusting it [20:25] GAH!! [20:25] parse_cmdline_data('ds=nocloud', fill, cmdline=cmdline) [20:25] True [20:25] >>> fill [20:25] {'instance-id': 'iid-raspberrypi-nocloud', 'seedfrom': '/boot/'} [20:26] brunobronosky: I think it's worth an update to documentation to show an example there [20:26] Yes! Moar Examples everywhere! [20:27] =) [20:32] woohoo! it created /var/lib/cloud/instances/iid-raspberrypi-nocloud that time. [20:32] \o/ [20:37] Now I'm wondering about this /var/lib/cloud/scripts/per-boot thing [20:38] for one. I noticce that it gets wiped out on `cloud-init clean` [20:41] yes, clean wipes the system to make it like "new" to cloud-init [20:45] right, per-boot; [20:46] holy carp! per-boot is working now. === r-daneel_ is now known as r-daneel [21:39] This is working pretty smooth. I've got per-boot working as a symlink to /boot/per-boot.sh [21:40] Now I need some design advice. [21:40] I guess I should describe the greater project at this point. I'll try to keep it short. [21:49] In 6 days, this project will be 5 years old! https://www.raspberrypi.org/forums/viewtopic.php?t=35224 The basic goal is to have a script in the vfat /boot partition of a newly imaged Raspbian microSD card that will get run on boot. [21:50] I've done this lots of ways over the years (mostly using rc.local) building dozens of single purpose machines. [21:53] My projects have been forked and reused and I'm feeling kind of bad about spreading bad habits. I've decided finally do it right and get it accepted into Raspbian. My options were to create my own oneshot systemd service, or use cloud-init. I'd like to keep it as Standardâ„¢ as possible. So, I'm leaning towards this. [21:56] well you're in good company here :) it's right in cloud-init's wheelhouse [21:57] Some other users have expanded my original intent to have both an "on-boot.sh" and a "run-once.sh". Both of them get run if they are present, but the later gets renamed run-once.$(date +%F@%H.%M.%S) after execution. [21:59] So here is the design question (finally): implementing my on-boot.sh with /var/lib/cloud/scripts/per-boot is pretty simple. Should I try to implement run-once.sh with /var/lib/cloud/scripts/per-once or stray from the cloud-init Standardâ„¢ for that? [22:02] my meaning of per-once is "per once, every time it reappears", and cloud-init's meaning of per-once is "per once, ever, dammit". (at least from what I can tell) [22:02] brunobronosky: I'm wondering why not per-instance instead of per-boot? per-boot is every boot [22:04] per-instance would only fire again if your NoCloud seed directories provide a different instance-id [22:04] and it wouldn't fire again across reboots [22:04] unless that data changed [22:07] or per-once might actually be what you need right, sorry because you only want to do that once ever [22:08] as long as your workflow never runs "cloud-init clean" per-once scripts will never fire again after that first boot [22:09] So, the target audience for this is students and teachers. I'm trying to both make it easy and teach good practices... fine line. I want there to a script that runs on every boot, because a LOT of users want that. [22:10] The per-instance is interesting. I didn't know the difference between per-once and per-instance. that gives me something to think about. [22:12] And yes, the per-boot is basically like rc.local, and that is the point. The difference is that a Windows (or Mac) user can mount the vfat partition and edit files in the /boot folder, but they cannot get to /etc. [22:13] if you don't expect metadata in the seed directory to change between boots when provisioning, per-instance effectively behaves like per-once. [22:14] yeah per-boot is probably what most folks would want; in their own per-boot script they'd be able to change behavior to only perform an operation once if they want to. [22:14] well, it least if gives the most flexibility I suppose. [22:18] So, is it terrible of me to use the names /boot/per-boot.sh and /boot/per-once.sh even though my per-once is totally different? Am I doing the student a disservice? [22:19] I just really like the consistency of the per-* and that they will sort together for the student to find. [22:20] brunobronosky: it could be useful to bikeshed a name for per-every-occurance.sh or something [22:20] I do think the per-once (and only once per instance) is pretty straightfoward in the cloud-init space; though I think outside of cloud-init , the 'instance' concept is not quite as clear [22:24] rharper yes, instance is totally unclear outside of the cloud paradigm. [22:25] I'd love to have rpi clusters be a gateway for teaching cloud concepts... but that is a big bite for a beginner. [22:26] brunobronosky: it may be useful then to include a script in your per-boot.sh which does an existance check on some directory, and if present call run-parts on it; [22:27] so you can tell users, if they create a directory named something your per-boot checks, it'll then call run-parts on it (which just executes any scripts/programs marked executable ) [22:27] nice! [22:28] (eveything is executable on vfat) [22:31] well, mount mask 0022 so... === brunobronosky is now known as brunobron-afk [22:47] brunobron-afk: lol @ vfat