1

I'm new to OPNSense (also to FreeBSD in general) and I'm interested to use cloud-init to configure at least LAN (vtnet0) with static ip address, root password and eventually running custom scripts (or shell commands) in a OPNsense VM created with Qemu to apply a custom configuration.

I saw that opnsense github repo has cloud-init port, so I installed it with:

pkg install net/cloud-init

Then I added cidata.iso image to Qemu as required by cloud-init NoCloud with user-data and meta-data. I already tested those files on ubuntu server 21 and kali linux. They are correct at least on those OSs ;)

I found the cdrom as /dev/cd0 and mounted with

mkdir -p /media/cdrom
mount -t cd9660 /dev/cd0 /media/cdrom

I also edited /etc/fstab appending this line:

/dev/cd0 /media/cdrom cd9660 ro 0 0

to auto mount the cdrom at boot.

Finally, I created (because unexisting) /etc/rc.conf with this content:

cloudinit_enable="YES"

and restarted my OPNsense VM.

What I expect now is that cloud-init will start automatically at boot.

However this doesn't happen, probably because I have to configure something. If I run cloud-init init via terminal it throws error:

stages.py[WARNING]: Failed to rename devices: Unexpected error while running command.
Command [`ip`, `-6`, `addr`,`show`, `permanent`, `scope`,`global`]
Exit code: -
Reason: [Errno 2] No such file or directory: b`ip`
Stdout: -
Stderr: -
No `init` modules to run under section `cloud_init_modules`

On both Kali Linux and Ubuntu Server it works easely.

I have some questions about this:

  1. Is it possible to use cloud-init port with NoCloud and a cdrom (cidata) with configuration files or it supports only Cloud services with OpenStack and so on?
  2. Is my configuration above correct or am I missing something?
  3. Why does it appear the error above? How can I fix it?

I already posted this question here, but I didn't receive answers.

7
  • Unfortunately I can't find a port for 'ip' command, which is related to the error you got. :(
    – rh0x
    Oct 7 at 15:43
  • this is not an answer to your question, but you might be interested in my fakecloud program that provides ec2-like metadata for VMs using cloudinit. Requires perl and the mojolicious library module. I wrote it because I found messing around with CD images to be too much of a PITA. The catch is that the iptables redirect rule in README.md is for linux - if you figure out how to do the same thing on freebsd, let me know and i'll update the README.
    – cas
    Oct 8 at 3:21
  • 1
    BTW, the reason why your cloudinit isn't working on freebsd is that freebsd doesn't use the ip program (from the Linux-specific iproute2 package). It uses ifconfig instead. To get it working, you'd have to modify cloudinit to use ifconfig and the appropriate ifconfig arguments. Looking at the github repo you linked to, it looks like the patch does make it use ifconfig, so it's very odd that it's still trying to run ip.
    – cas
    Oct 8 at 4:29
  • I ran pkg search cloud-init on my freebsd 13.0-RELEASE-p4 VM and noticed that it had a package called py38-cloud-init-20.4.1_2 Init scripts for use on cloud images. I don't use it (because it's not an image for use on amazon or openstack etc, it's just a VM with a dhcp client), so i have no idea if it's any different to or better than what you've got.
    – cas
    Oct 8 at 4:30
  • @cas thank you for your comments. Running pkg search cloud-init I get py38-cloud-init-21.2. You are right about the github repo, because it seems that patch files are already available and they are applied correctly to /usr/local/lib/python3.8/site-packages/cloudinit. I don't know which python file is still trying to use ip. Oct 8 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.