-
Notifications
You must be signed in to change notification settings - Fork 981
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
#2572 implement freebsd support #673
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class Freebsd < Operatingsystem | ||
# We don't fetch any PXEFILES! | ||
# Please copy your mfsbsd boot image into the tftp area. | ||
# | ||
# -as kernel we will use memdisk | ||
# -as initrd we will use your custom FreeBSD-<arch>-<version>-mfs.img in boot | ||
PXEFILES = {} | ||
|
||
def class | ||
Operatingsystem | ||
end | ||
|
||
def pxe_type | ||
"memdisk" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm.. should we call it maybe differently? so if later on we use memdisk for something else? (or more specific to bsd) |
||
end | ||
|
||
def pxedir | ||
"boot/$arch/images" | ||
end | ||
|
||
def url_for_boot(file) | ||
pxedir + "/" + PXEFILES[file] | ||
end | ||
|
||
def kernel arch | ||
"memdisk" | ||
end | ||
|
||
def initrd arch | ||
"boot/FreeBSD-#{arch}-#{release}-mfs.img" | ||
end | ||
|
||
def mediumpath host | ||
arch = host.architecture.name.to_s.gsub("x86_64","amd64") | ||
"#{medium_uri(host)}/releases/#{arch}/#{release}-RELEASE" | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Basic pc-sysinstall based configuration | ||
# | ||
# | ||
installInteractive=no | ||
installMode=fresh | ||
installType=FreeBSD | ||
|
||
# install source configuration | ||
installMedium=ftp | ||
ftpPath=<%= @mediapath %> | ||
packageType=tar | ||
|
||
# base package name | ||
installFile=base.txz | ||
|
||
# set hostname | ||
hostname=<%= @host.name %> | ||
|
||
# enable DHCP on all interfaces | ||
netDev=AUTO-DHCP | ||
|
||
# inject the disk layout | ||
<%= @host.diskLayout %> | ||
|
||
# mount devfs | ||
runExtCommand=mount -t devfs devfs ${FSMNT}/dev | ||
|
||
# get and install kernel component | ||
runExtCommand=fetch -o /mnt/tmp/kernel.txz <%= @mediapath %>/kernel.txz | ||
runCommand=tar -xzf /tmp/kernel.txz | ||
runCommand=rm /tmp/kernel.txz | ||
|
||
# copy resolv.conf to enable dns in chroot | ||
runExtCommand=cp /etc/resolv.conf /mnt/etc/resolv.conf | ||
|
||
# install packages | ||
runCommand=pkg_add -r puppet | ||
runCommand=pkg_add -r wget | ||
|
||
# Root Password | ||
rootEncPass=<%= root_pass %> | ||
|
||
# setup rc.conf | ||
runCommand=echo 'sshd_enable="YES"' >>/etc/rc.conf | ||
runCommand=echo 'ntpd_enable="YES"' >>/etc/rc.conf | ||
|
||
# setup basic networking | ||
runCommand=echo 'ifconfig_bge0="DHCP"' >>/etc/rc.conf | ||
runCommand=echo 'ifconfig_em0="DHCP"' >>/etc/rc.conf | ||
runCommand=echo 'ifconfig_igb0="DHCP"' >>/etc/rc.conf | ||
runCommand=echo 'ifconfig_bce0="DHCP"' >>/etc/rc.conf | ||
runCommand=echo 'ifconfig_nfe0="DHCP"' >>/etc/rc.conf | ||
runCommand=hostname <%= @host.shortname %> | ||
|
||
# Set up date/time | ||
runCommand=cp /usr/share/zoneinfo/UTC /etc/localtime | ||
runCommand=touch /etc/wall_cmos_clock | ||
runCommand=adjkerntz -a | ||
|
||
# fetch and run finish template | ||
runExtCommand=fetch -o /mnt/tmp/finish.sh <%= foreman_url("finish") %> | ||
runCommand=chmod +x /tmp/finish.sh; /tmp/finish.sh | ||
|
||
#Clean up and reboot | ||
runExtCommand=umount ${FSMNT}/dev | ||
runCommand=shutdown -r now | ||
runExtCommand=shutdown -r now |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cat > /usr/local/etc/puppet/puppet.conf << EOF | ||
<%= snippets "puppet.conf" %> | ||
EOF | ||
/usr/local/bin/augtool -s set /files/etc/rc.conf/puppet_enable '\"YES\"' | ||
/usr/bin/touch /usr/local/etc/puppet/namespaceauth.conf | ||
/usr/local/bin/puppet agent --config /urs/local/etc/puppet/puppet.conf --onetime --tags no_such_tag --server <%= @host.puppetmaster %> | ||
/usr/local/bin/wget --quiet --output-document=/dev/null --no-check-certificate <%= foreman_url %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
default freebsd | ||
label freebsd | ||
kernel memdisk | ||
append initrd=<%= @initrd %> harddisk raw |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
class FreebsdOsSupport < ActiveRecord::Migration | ||
|
||
class Medium < ActiveRecord::Base | ||
has_and_belongs_to_many :operatingsystems | ||
end | ||
|
||
class ConfigTemplate < ActiveRecord::Base | ||
has_and_belongs_to_many :operatingsystems | ||
end | ||
|
||
def up | ||
TemplateKind.all.each do |kind| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we might want to add those templates to the community templates repo? |
||
case kind.name | ||
when /provision/ | ||
ConfigTemplate.create( | ||
:name => "Memdisk Default", | ||
:template_kind_id => kind.id, | ||
:operatingsystem_ids => Freebsd.all.map(&:id), | ||
:template => File.read("#{Rails.root}/app/views/unattended/memdisk.rhtml")) | ||
when /finish/ | ||
ConfigTemplate.create( | ||
:name => "Memdisk Default Finish", | ||
:template_kind_id => kind.id, | ||
:operatingsystem_ids => Freebsd.all.map(&:id), | ||
:template => File.read("#{Rails.root}/app/views/unattended/memdisk_finish.rhtml")) | ||
when /pxelinux/i | ||
ConfigTemplate.create( | ||
:name => "Memdisk default PXElinux", | ||
:template_kind_id => kind.id, | ||
:operatingsystem_ids => Freebsd.all.map(&:id), | ||
:template => File.read("#{Rails.root}/app/views/unattended/pxe_memdisk_config.erb")) | ||
end | ||
end | ||
|
||
os = Operatingsystem.find_all_by_type "Freebsd" || Operatingsystem.where("name LIKE ?", "freebsd") | ||
disk = Ptable.create :name => "FreeBSD Disk small", :layout => "# Disk Setup\ndisk0=ada0\npartition=ALL\nbootManager=bsd\npartscheme=GPT\ncommitDiskPart\n\n# Partition Setup for da0(ALL)\n# All sizes are expressed in MB\n# Avail FS Types, UFS, UFS+S, UFS+SUJ, UFS+J, ZFS, SWAP\n# UFS.eli, UFS+S.eli, UFS+SUJ, UFS+J.eli, ZFS.eli, SWAP.eli\ndisk0-part=UFS+SUJ 1000 /\ndisk0-part=SWAP 512 none\ndisk0-part=UFS+SUJ 512 /var\ncommitDiskLabel" | ||
|
||
medium = Medium.create :name => "FreeBSD mirror", :path => "ftp://ftp.freebsd.org/pub/FreeBSD" | ||
medium.operatingsystems = os | ||
|
||
rescue Exception => e | ||
# something bad happened, but we don't want to break the migration process | ||
Rails.logger.warn "Failed to migrate #{e}" | ||
say "Failed to migrate #{e}" | ||
return true | ||
|
||
end | ||
|
||
def down | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of 1.3 and later this file should be stored under app/models/operatingsystems/freebsd.rb