All Projects → jlduran → packer-FreeBSD

jlduran / packer-FreeBSD

Licence: MIT license
Build a FreeBSD VM for Vagrant using packer

Programming Languages

shell
77523 projects
HCL
1544 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to packer-FreeBSD

Bento
Packer templates for building minimal Vagrant baseboxes for multiple platforms
Stars: ✭ 3,779 (+16330.43%)
Mutual labels:  freebsd, vagrant, packer, virtualbox
insaneworks-packer-template
CentOS 7-8 8Stream / AlmaLinux 8 / FreeBSD 12 - 13 x64 + VirtualBox / VMWare for Packer Template + FreeBSD 13 / AlmaLinux 9 + Parallels
Stars: ✭ 38 (+65.22%)
Mutual labels:  freebsd, vagrant, packer, virtualbox
Robox
The tools needed to robotically create/configure/provision a large number of operating systems, for a variety of hypervisors, using packer.
Stars: ✭ 303 (+1217.39%)
Mutual labels:  freebsd, vagrant, packer, virtualbox
packer-centos
Create CentOS images for different hypervisors with Packer
Stars: ✭ 18 (-21.74%)
Mutual labels:  vagrant, packer, virtualbox
Packer Centos 6
This build has been moved - see README.md
Stars: ✭ 78 (+239.13%)
Mutual labels:  vagrant, packer, virtualbox
Packer Ubuntu 1404
DEPRECATED - Packer Example - Ubuntu 14.04 Vagrant Box using Ansible provisioner
Stars: ✭ 81 (+252.17%)
Mutual labels:  vagrant, packer, virtualbox
Beetbox
Pre-provisioned L*MP stack
Stars: ✭ 94 (+308.7%)
Mutual labels:  vagrant, packer, virtualbox
Packer Ubuntu 1804
This build has been moved - see README.md
Stars: ✭ 101 (+339.13%)
Mutual labels:  vagrant, packer, virtualbox
Nixbox
NixOS Vagrant boxes [[email protected]]
Stars: ✭ 189 (+721.74%)
Mutual labels:  vagrant, packer, virtualbox
Packer Centos 7
This build has been moved - see README.md
Stars: ✭ 223 (+869.57%)
Mutual labels:  vagrant, packer, virtualbox
Packer Templates
Scripts and Templates used for generating Vagrant images
Stars: ✭ 219 (+852.17%)
Mutual labels:  vagrant, packer, virtualbox
Packer
Packer helpers and templates for Docker, IIS, SQL Server and Visual Studio on Windows and Ubuntu
Stars: ✭ 242 (+952.17%)
Mutual labels:  vagrant, packer, virtualbox
Osx Vm Templates
macOS templates for Packer and VeeWee.
Stars: ✭ 1,050 (+4465.22%)
Mutual labels:  vagrant, packer, virtualbox
Packer Boxes
Jeff Geerling's Packer build configurations for Vagrant boxes.
Stars: ✭ 495 (+2052.17%)
Mutual labels:  vagrant, packer, virtualbox
Packer Templates
Stars: ✭ 90 (+291.3%)
Mutual labels:  vagrant, packer, virtualbox
Packer Templates
Packer templates for Vagrant base boxes
Stars: ✭ 471 (+1947.83%)
Mutual labels:  vagrant, packer, virtualbox
Vagrant Boxes
baseboxes build with packer.io for use with vagrant
Stars: ✭ 291 (+1165.22%)
Mutual labels:  vagrant, packer, virtualbox
New-Machine
Utilizing Vagrant, Packer, Chocolatey, and Boxstarter to Configure my Dev Machines
Stars: ✭ 26 (+13.04%)
Mutual labels:  vagrant, packer, virtualbox
packer-ubuntu-18.04
packer example - Ubuntu Server 18.04.5
Stars: ✭ 37 (+60.87%)
Mutual labels:  vagrant, packer, virtualbox
Packer Build
Packer Automated VM Image and Vagrant Box Builds
Stars: ✭ 199 (+765.22%)
Mutual labels:  vagrant, packer, virtualbox

packer-FreeBSD

This repository contains the necessary tools to build a Vagrant-ready FreeBSD virtual machine using Packer.

There are official FreeBSD VMs available from the Vagrant Cloud.

Prerequisites

Instructions

To create a box:

  1. Clone this repository:

    $ git clone https://github.com/jlduran/packer-FreeBSD.git
    $ cd packer-FreeBSD
    
  2. Build the box:

    $ packer build .
    
  3. Add it to the list of Vagrant boxes. See Handling .iso and .box files for more information.

    $ vagrant box add builds/FreeBSD-13.1-RELEASE-amd64.box --name FreeBSD-13.1-RELEASE-amd64
    

Sample Vagrantbox file

servers = [
  { name: 'www.local', cpus: 2, memory: 1024 },
  { name: 'db.local', cpus: 1, memory: 2048 }
]

script = <<-SCRIPT
  sed -i '' "s/Vagrant/$(hostname -s)/g" /usr/local/etc/mDNSResponderServices.conf
  service mdnsresponderposix restart
SCRIPT

ansible_raw_arguments = []

Vagrant.configure(2) do |config|
  servers.each do |server|
    config.vm.define server[:name] do |box|
      box.vm.box      = 'FreeBSD-13.1-RELEASE-amd64'
      box.vm.hostname = server[:name]
      box.vm.provider 'virtualbox' do |v|
        v.default_nic_type       = 'virtio'
        v.linked_clone           = true
        v.name, v.cpus, v.memory = server.values_at(:name, :cpus, :memory)
      end

      if server == servers.last
        box.vm.provision 'ansible' do |ansible|
          ansible.compatibility_mode = '2.0'
          ansible.limit              = 'all'
          ansible.playbook           = 'site.yml'
          ansible.inventory_path     = 'local'
          ansible.raw_arguments      = ansible_raw_arguments
        end
      else
        ansible_raw_arguments << private_key_path(server[:name])
      end
    end
  end

  config.vm.provision 'shell', inline: script
end

def private_key_path(server_name)
  provider = ENV['VAGRANT_DEFAULT_PROVIDER'] || 'virtualbox'
  vagrant_dotfile_path = ENV['VAGRANT_DOTFILE_PATH'] || '.vagrant'

  "--private-key=#{vagrant_dotfile_path}/machines/#{server_name}/" \
    "#{provider}/private_key"
end

Build Options

Below is a sample variables.pkrvars.hcl file:

arch          = "amd64"
branch        = "-RELEASE"
build_date    = ""
cpus          = 1
directory     = "releases"
disk_size     = 10240
filesystem    = "zfs"
git_commit    = ""
guest_os_type = "FreeBSD_64"
memory        = 1024
mirror        = "https://download.freebsd.org"
rc_conf_file  = ""
revision      = "13.1"

The following variables can be set:

  • cpus is the number of CPUs assigned. Default: 1

  • disk_size is the HDD size in megabytes. Default: 10240

  • memory is the amount of RAM in megabytes assigned. Default: 1024

  • revision is the FreeBSD revision number. Default: 13.1

  • branch used in conjunction with build_date, git_commit and directory. Default: -RELEASE

    See FreeBSD's Release Branches for more information. Possible values are:

    Branch Directory
    -CURRENT snapshots
    -STABLE snapshots
    -ALPHA1, -ALPHA2, … snapshots
    -PRERELEASE snapshots
    -BETA1, -BETA2, … releases
    -RC1, -RC2, … releases
    -RELEASE releases
  • arch is the target architecture (i386 or amd64). Default: amd64

  • guest_os_type (VirtualBox) used in conjunction with arch (FreeBSD or FreeBSD_64). See packer's documentation. Default: FreeBSD_64

  • filesystem is the file system type (ufs or zfs). Default: zfs

  • mirror is the preferred FreeBSD mirror. Default: https://download.freebsd.org

  • rc_conf_file is the file where rc.conf parameters are stored. Default: empty . Possible values are:

    Value File
    /etc/rc.conf
    local /etc/rc.conf.local (Its use is discouraged)
    vendor /etc/defaults/vendor.conf
    name (/usr/local)/etc/rc.conf.d/<name>

Create a variables.pkrvars.hcl file overriding the default values, and invoke:

$ packer build -var-file="variables.pkrvars.hcl" .

You can also select which components you wish to install. By default, it runs the following provisioning scripts:

Name Description
update Updates to the latest patch level (if applicable) and the latest packages
vagrant Vagrant-related configuration
zeroconf Enables zero-configuration networking
ansible Installs python and CA Root certificates
vmtools Virtual Machine-specific utilities
cleanup Cleanup script (must be called last)

The following scripts are also available:

Name Description
hardening Provides basic hardening options
ports Installs the FreeBSD ports tree

Handling .iso and .box files

Packer will automatically download the .iso image if it does not find the right one under the iso directory. Optionally, you can download the .iso image and save it to the iso directory.

.box files will be created under the builds directory.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].