Per instance contexts


I’ve been toying with 4.14b1 for a couple of days now and it looks really nice and simple, but I have one question (for now), how can I contextualize various stuff per instance?

I’d like for example to set a ROOT_PASSWORD that the VM can use and apply at creation and so on.



You’re looking for something like this:

There’s also the opennebula-context package, you might want to install on your OS disks

I haven’t tried any of them, as I am using my own scripts.
Assuming your template template defines some USERPASS, and maybe some USERNAME (my script sets it to ‘root’ if empty), then you may use something like this:

. /mnt/ [...] if test "$USERPASS"; then echo "$USERNAME:$USERPASS" | chpasswd fi if test "$SSH_PUBLIC_KEY"; then mkdir -p $HOMEDIR/.ssh echo "$SSH_PUBLIC_KEY oneadmin@nebula" >>$HOMEDIR/.ssh/authorized_keys chown -R $USERNAME:$USERNAME $HOMEDIR/.ssh find $HOMEDIR/.ssh -type f -exec chmod 0600 {} \; find $HOMEDIR/.ssh -type d -exec chmod 0700 {} \; if test "$USERNAME" = root; then ssh-keygen -t dsa -N '' -f id_dsa else su -l $USERNAME -c "ssh-keygen -t dsa -N '' -f id_dsa" fi fi

An other snippet that would help you finding your CONTEXT disk:

local isdone
test “$1” || return 2
if mount -t iso9660 /dev/$1 /mnt >/dev/null 2>&1; then
if test -s /mnt/; then
umount /mnt
if $isdone; then
return 0

return 1


if test -L /dev/disk/by-label/CONTEXT; then
try_disk disk/by-label/CONTEXT
for dev in awk '{print $3}' /proc/diskstats
echo $dev | grep loop >/dev/null && continue
try_disk $dev && break
if test -L /dev/disk/by-label/swap; then
swapon -L swap

Then, some ugly way to do it would be do patch your /etc/rc.local with the following:

if test -e /oneboot; then . /usr/lib/nebula/context-init nebula_generic_cloud_init rm -f /oneboot fi

Thanks Samuel, what I am after is a way to sey a root password per instance.
i know the template allows me to set $ROOT_PASSWORD=XYZ, but I need “XYZ” to be something I am setting per VM/instance, so each machine has its own individual and unique password etc.

I don’t see any feature like the above, at least not in the UI or docs.



You can set a different password each time the template is instantiated with the template user inputs:

Holy cow, those input+context things can potentially be very powerful, thanks for letting me know.