diff options
| author | Baptiste Daroussin <bapt@FreeBSD.org> | 2022-11-23 19:00:39 +0000 |
|---|---|---|
| committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2024-04-11 11:52:52 +0000 |
| commit | 16a6da44e28d607f2383be7c7c325090979f531f (patch) | |
| tree | de938203ebf1b28b72dfd8d496c4ad19b4fe7040 /libexec/rc/rc.d/nuageinit | |
| parent | 7ced57106295ac92a0584ea03e0a05b66973ed73 (diff) | |
nuageinit: add basic support for cloudinit.
this is a very early script to support cloudinit, it does not intend to
be a full featured cloudinit client, but will support a good enough
subset to be viable in most case.
It support nocloud and openstack config-2 config drive mode (iso9660 or
msdosfs)
The following features are currently supported:
- adding users (including a default user named 'freebsd' with password
'freebsd'
- adding groups
- adding ssh keys
- static ipv4, static ipv6, dynamic ipv4
With this one is able to use the 'bring your own image feature" out of
box.
It is expected that the script grows the support of other clouds
supporting cloud-init, contributions are welcomed.
It is designed to be only run once via the firstboot mecanism.
Sponsored by: OVHCloud
Differential Revision: https://reviews.freebsd.org/D44141
(cherry picked from commit a42d6f76018e4ed8324e319ab48aac904bda437c)
(cherry picked from commit c051f22bce42d920abba61bd7cf4ef5b6a270ffa)
(cherry picked from commit b8c053c9a612651d4909f7a323088f3e92485b7b)
(cherry picked from commit 9eae9233fdcc946945f4191e1413f548adfa2943)
Diffstat (limited to 'libexec/rc/rc.d/nuageinit')
| -rwxr-xr-x | libexec/rc/rc.d/nuageinit | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/libexec/rc/rc.d/nuageinit b/libexec/rc/rc.d/nuageinit new file mode 100755 index 000000000000..977b44e465fe --- /dev/null +++ b/libexec/rc/rc.d/nuageinit @@ -0,0 +1,67 @@ +#!/bin/sh +# + +# PROVIDE: nuageinit +# REQUIRE: mountcritlocal +# BEFORE: NETWORKING +# KEYWORD: firstboot + +. /etc/rc.subr + +name="nuageinit" +desc="Limited Cloud Init configuration" +start_cmd="nuageinit_start" +stop_cmd=":" +rcvar="nuageinit_enable" + +nuageinit_start() +{ + local citype + # detect cloud init provider + # according to the specification of the config drive + # it either formatted in vfat or iso9660 and labeled + # config-2 + for f in iso9660 msdosfs; do + drive="/dev/$f/[cC][oO][nN][fF][iI][gG]-2" + if [ -e $drive ]; then + citype=config-2 + break + fi + drive="/dev/$f/[cC][iI][dD][aA][tT][aA]" + if [ -e $drive ]; then + citype=nocloud + break + fi + unset drive + done + if [ -z "$drive" ]; then + # try to detect networked based instance + err 1 "Impossible to find a cloud init provider" + fi + mkdir -p /media/nuageinit + fs=$(fstyp $drive) + mount -t $fs $drive /media/nuageinit + # according to the specification, the content is either + # in the openstack or ec2 directory + case "$citype" in + config-2) + for d in openstack ec2; do + dir=/media/nuageinit/$d/latest + if [ -d $dir ]; then + /usr/libexec/nuageinit $dir $citype + break + fi + done + ;; + nocloud) + /usr/libexec/nuageinit /media/nuageinit $citype + ;; + esac + if [ -n "$drive" ]; then + umount /media/nuageinit + fi + rmdir /media/nuageinit +} + +load_rc_config $name +run_rc_command "$1" |
