Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add freebsd support #8

Open
kayrus opened this issue Mar 1, 2016 · 5 comments
Open

Add freebsd support #8

kayrus opened this issue Mar 1, 2016 · 5 comments

Comments

@kayrus
Copy link
Owner

kayrus commented Mar 1, 2016

https://pellaeon.github.io/bsd-cloudinit/

@merovigen
Copy link

Hey kayrus.
I tested cloud-init on FreeBSD 10 and can tell you that bsd-cloudinit does not support NoCloud and ConfigDrive datastores. For my project I used cloud-init 0.7.7 (it does support FreeBSD, but not in official way).
Just need to disable "sync" mounting by default and add distro password changing method.
If you are interested, please let me know and I'll share my investiations.

@kayrus
Copy link
Owner Author

kayrus commented Sep 21, 2016

sure. I test lot of macos related stuff in freebsd. and I have to recreate freebsd VMs quite frequently. sshkeys/network configuration takes a lot of time

@merovigen
Copy link

Unfortunately, I didn't fork cloud-init on github and can't show you code examples, but I am planning to do this.
So, here are changes, that I made to cloud-init 0.7.7:

  1. make password changing disto-specific
--- a/cloudinit/config/cc_set_passwords.py
+++ b/cloudinit/config/cc_set_passwords.py
@@ -75,8 +75,10 @@ def handle(_name, cfg, cloud, log, args):

         ch_in = '\n'.join(plist_in) + '\n'
         try:
-            log.debug("Changing password for %s:", users)
-            util.subp(['chpasswd'], ch_in)
+            log.debug("Changing password for %s: %s", users, ch_in)
+            us, pa = ch_in.split(':', 1)
+            cloud.distro.set_passwd(us, pa)
+            # util.subp(['chpasswd'], ch_in)
         except Exception as e:
             errors.append(e)
             util.logexc(log, "Failed to set passwords with chpasswd for %s",
  1. comment sync mounting (I am sure there is a better way to do it):
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -1601,10 +1601,10 @@ def mount_cb(device, callback, data=None, rw=False, mtype=None, sync=True):
                         mountopts.append('rw')
                     else:
                         mountopts.append('ro')
-                    if sync:
+                    #if sync:
                         # This seems like the safe approach to do
                         # (ie where this is on by default)
-                        mountopts.append("sync")
+                    #    mountopts.append("sync")
                     if mountopts:
                         mountcmd.extend(["-o", ",".join(mountopts)])
                     if mtype:

Here are steps to install cloud-init package on FreeBSD 10:

  1. install python setuptools (AFAIR, package name is py-setuptools)
  2. install package e2fsprogs (to use blkid)
  3. install cloud-init python2.7 setup.py install --init-system=sysvinit_freebsd
  4. by default installer brings you cloud.cfg for ubuntu although there is config for FreeBSD, so be sure to check /usr/local/etc/cloud/cloud.cfg for proper options
  5. on FreeBSD config files from /usr/local/etc/cloud/cloud.cfg.d does not work (I did not manage to guess why), so to use proper logging you should move logging settings to main config
  6. To minimize cloud-init datastore searching time I edited datastore_list in config and left only preffered datasources (NoCloud and ConfigDrive)
  7. Finally, you need to activate cloud-init in /etc/rc.conf: cloudinit_enable="YES"

I use static network settings in meta-data file with NoCloud and it works perfectly, renaming interface and commiting settings in /etc/rc.conf. But there is one little problem - on first boot after customizing routing does not start, so I added command /etc/rc.d/routing start to runcmd.
Root user password changing and ssh key commiting works too. Didn't try other functions like package installing though.

@kayrus
Copy link
Owner Author

kayrus commented Sep 21, 2016

i'll test these changes this week.
p.s. There should be a way to propose these patches to freebsd developers.

@merovigen
Copy link

merovigen commented Sep 21, 2016

I used cloud-init from launchpad, not from FreeBSD ports.
Actually, I didn't know there is a port for it) So I'll test it too to see the difference.

EDIT:
checked freebsd port version of cloud-init 0.7.6
There are the same problems, starting from blkid utility missing and to the config problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants