FreeBSD Provisioning Ansible collection

Hi everyone,

I wanted to share with the community a rather extensive Ansible collection I've been working on for months to provision FreeBSD hosts, taking care of, on a per Ansible role basis:
  • Node bootstrapping (e.g. installing Python, configuring SSH, installing "core" packages, etc).
  • OS patching.
  • Host tuning (e.g. limited hardware configuration, e.g. CPU microcode, power levels, etc.).
  • Boot-time settings (e.g. kernel modules to load, kernel tunables, etc.).
  • Runtime settings (e.g. various runtime sysctl's).
  • Network (e.g. various types of interfaces, DNS resolver, etc.).
  • Monitoring (e.g. boot notifications, SSH abuse, select services availability, etc.).
  • ZFS (pool importing, automated encrypted datasets unlocking, replication, etc.)
  • Users & groups.
  • Samba Server (main configuration, shares configuration, and user management).
  • NFSv4 Server (tuning and shares configuration).
  • NFS Client (tuning and shares mounting).
  • vm-bhyve based VM management.
  • Bastille based jail management.
All of these were developed as a solution to the challenge that migrating my workloads away from TrueNAS CORE posed to me, because I didn't want to continue on the legacy 13.3 OS, but I also didn't want to turn to some new alternative that would, again, completely hijack OS administration away from me.

With this solution, I can fully deploy my workloads to vanilla FreeBSD and retain full control of the OS, either via direct command line administration, updating the roles and inventory configuration and rerunning the automation suite or, most probably, both.

So, without any further ado, here's the source code, with some documentation scattered throughout (top-level README and then per-role README's): https://github.com/AP-Labs-IO/FreeBSD-Provisioning

Like I said, this automation suite was developed over several months to migrate all my workloads away from TrueNAS CORE, and it worked wonders for that in a single pass when I finally pulled the trigger (after much rehearsing in a VM), but, of course, it can still be considered a work in progress. So, please feel free to offer any feedback you might have!

And if you'd like me to describe how I upgraded to vanilla FreeBSD 15.1 on the legacy freenas-boot pool, while preserving the ability to boot back into TrueNAS should there be any need for it (verified, but luckily unnecessary so far), let me know and I'll create a quick write up.

Thank you!

Cc vermaden toddg JohnK
 
Nice! What are your thoughts on pyinfra? It doesn't need Python on the target host as it translates everything to POSIX shell and apparently it's also faster.
 
Nice! What are your thoughts on pyinfra? It doesn't need Python on the target host as it translates everything to POSIX shell and apparently it's also faster.
Thank you for the feedback! I hadn't heard about pyinfra, I'll look into it. But, at least off the top of my head, I'd figure that the savings wouldn't be that big in the long run… like it or not, Python is so ubiquitous now a'days that sooner or later it ends up being installed via some dependency chain, so I guess I just went with the flow and relied on the simplest possible setup for this automation stack.
 
Thanks, I've been liking Ansible for updating my 2 linux boxes and I'd been considering learning it for FreeBSD, but I haven't had much ambition to do so. I'll definitely have to take a look at this and see if there's something to be learned.
 
Thanks, I've been liking Ansible for updating my 2 linux boxes and I'd been considering learning it for FreeBSD, but I haven't had much ambition to do so. I'll definitely have to take a look at this and see if there's something to be learned.
I hope it's useful to you!

As it pertains to Ansible proper, and if you're already familiar with t, I don't think there's much new to learn from this collection, because it's pretty much vanilla Ansible from start to finish, nothing too fancy (so much so that, as you can see in its Galaxy dependencies declaration, I only depend on two very common upstream collections other than ansible.posix).

The value I think this collection does add is that it is very thorough in how it takes a stock FreeBSD installation and automates from start to finish a wide variety of non-trivial configurations over multiple areas that you'd expect to find in either a NAS and/or a virtualization server, as described throughout its varios README files.

Please do let me know if you run into any problems using any of its roles, I've been meaning to add more documentation and usage examples but I've been swamped these last days, so I'm not too sure to what degree what I already wrote is of use to others.

The one thing I would recommend is to snapshot your root volume / boot environment before starting, if possible, so you can revert back to a pristine state in case something doesn't work as expected.
 
I've now made an "official" 1.0.0 release of my collection and published it to Ansible Galaxy:


which makes it a tad simpler to install via an ansible-galaxy invocation:

sh:
ansible-galaxy collection install ap_labs.freebsd_provisioning

Or via a requirements.yml file collections declaration:

YAML:
collections:
  - name: ap_labs.freebsd_provisioning
    version: ">=1.0.0"

sh:
ansible-galaxy collection install -r requirements.yml

Of course, the previous git+ssh transport still works if you wish to install from GitHub to get any new code I might have not yet tagged and published to Galaxy:

YAML:
collections:
  - name: git+ssh://git@github.com/AP-Labs-IO/FreeBSD-Provisioning.git
    version: main

Enjoy!
 
Wow, this is nice as a fellow CORE last holdouts. I have just been holding off the migration because I am super lazy and a super procrastinator.

Curious question: What made you choose Ansible over others like Puppet, Salt, etc?
 
Wow, this is nice as a fellow CORE last holdouts. I have just been holding off the migration because I am super lazy and a super procrastinator.
Hopefully this collection will help you pull the trigger and migrate away from very-quickly-bitrotting CORE sooner than later. I spent months working on it to get everything right, analyzing all of my uses and configurations of TrueNAS, and every single config file underneath /etc, /usr/local/etc, /boot, etc., to divide them into logical roles, and then taking each one of them, and also various combinations of them, through extensive testing in a VM that I'd frequently roll back to a pristine state to ensure everything worked as intended, from scratch and out-of-the box with a preconfigured inventory and with no human intervention. And once the whole thing was ready and I pulled the trigger to migrate my server, it was a very enjoyable and well-worth single night of downtime, with a fully-patched FreeBSD 15.1 server that came out on the other side fully configured with my VLANs and bridges, VMs, jails, NFS server, Samba server & shares, data pools & encrypted ZFS datasets auto-imported, snapshotting & replication schedules, monitoring, users & groups, boot & runtime tuning, etc.

I'm still pending some documentation that'd illustrate what a full inventory might look like, but at least each role's README already has a full description of that the variables it exports look like. Please feel free to reach out if any of it is hard to grok.

I'm also working on a quick tutorial on how to install vanilla FreeBSD into a new boot environment of the freenas-boot pool while retaining the ability to boot back into that OS, should you need to, as that's a good safety net to keep around, at least for a while, if you fear a migration away from CORE might be a tad too disruptive to your operations.


Curious question: What made you choose Ansible over others like Puppet, Salt, etc?
In all honesty, just prior experience. I prefer an agent-less approach, as I feel that simplifies things considerably, and within that realm of tools Ansible was the one I had more experience with, so it was natural for me to choose it to flesh out my migration.
 
Back
Top