Commit deec7cbb authored by Christopher Huhn's avatar Christopher Huhn
Browse files

Refine fai_config resource and use it for default setup

parent 2efd9102
......@@ -4,7 +4,7 @@ maintainer_email "hpc@gsi.de"
license "All rights reserved"
description "Installs/Configures fai"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.10.0"
version "1.0.0"
depends "nfs", '< 4'
source_url 'https://git.gsi.de/chef/cookbooks/fai'
......
......@@ -55,72 +55,19 @@ end
# There have been some changes to FAI v4, which is shipped on Wheezy
nfsroot_config = "nfsroot.conf"
# If fai.config_source is not set, fall back to a default nfs URL
unless node['fai']['config_source'] == nil
fai_config_source = "nfs://#{node['ipaddress']}:#{node['fai']['configdir']}"
else
fai_config_source = node['fai']['config_source']
end
#setup fai config(s)
template "/etc/fai/fai.conf" do
source "fai.conf.erb"
variables({
:config_src => fai_config_source
})
mode 0644
end
directory node['fai']['nfsroot-hooks']
template "/etc/fai/#{nfsroot_config}" do
source "make-fai-nfsroot.conf.erb"
variables({
:config_src => fai_config_source,
:codename => node['lsb']['codename'],
:debmirror_url => node['fai']['debmirror_url'],
:nfsdir => "/srv/fai/nfsroot",
# install kernel into a flavor specific subdir for distinction:
:tftpdir => "/srv/tftp/#{node['lsb']['codename']}/#{node['debian']['architecture']}" +
"/fai#{node['debian']['packages']['fai-server']['version']}/",
:arch => "",
:hookdir => node['fai']['nfsroot-hooks']
})
mode 0644
end
template "/etc/fai/apt/sources.list" do
source "fai_sources.list.erb"
mode 0644
variables(
:codename => node['lsb']['codename'],
:debmirror_url => node['fai']['debmirror_url'],
:additional_sources => node['fai']['additional_sources']
)
end
template "/etc/fai/apt/apt.conf" do
source "fai_apt.conf.erb"
variables({
:install_recommends => node['fai']['install_recommends'],
:install_suggests => node['fai']['install_suggests']
})
end
# use the system sources.list:
# OH FUCK- OUR CHEF VERSION IS TOO OLD - ALL BLAME ON DEBIAN - WE HAVE TO SWITCH TO ...
#remote_file "/etc/fai/apt/sources.list" do
# source "file:///etc/apt/sources.list"
#end
template "/etc/fai/NFSROOT" do
source "NFSROOT.erb"
variables(
:extra_pkgs => node['fai']['common_extra_pkgs']
)
mode 0644
notifies :run, "execute[update-nfsroot]" #, :immediately ???
#setup default fai config
fai_config 'default' do
nfsroot_config_dir '/etc/fai'
nfsroot_dir '/srv/fai/nfsroot'
tftpdir ['/srv/tftp', node['lsb']['codename'],
node['debian']['architecture'],
# install kernel into a flavor specific subdir for distinction:
"fai#{node['debian']['packages']['fai-server']['version']}"
].join('/')
hook_dir node['fai']['nfsroot-hooks']
additional_sources node['fai']['additional_sources']
notifies :run, 'execute[update-nfsroot]', :immediately
end
# update the nfsroot:
......
......@@ -2,9 +2,24 @@
# Cookbook Name:: fai
# Recipe:: flavors
#
# Copyright 2011-2016, GSI Darmstadt
# Copyright 2012-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
#
# All rights reserved - Do Not Redistribute
# Authors:
# Christopher Huhn <c.huhn@gsi.de>
# Dennis Klein <d.klein@gsi.de>
# Bastian Neuburger <b.neuburger@gsi.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# recipe for configuring multiple FAI nfsroots on a single server in parallel
#
......@@ -35,7 +50,7 @@ node['fai']['flavors'].each do |f, config|
# f is something like squeeze-amd64
codename = config['codename'] || f.split("-")[0]
arch = config['arch'] || f.split("-")[1]
# FIXME: hanlde flavors like "codename-arch-bla-blubb"
# FIXME: handle flavors like "codename-arch-bla-blubb"
suffix = (f.split("-")[2..-1] || []).join('_')
nfs_dir = "/srv/fai/nfsroot-#{f}"
......@@ -81,7 +96,7 @@ node['fai']['flavors'].each do |f, config|
:nfsdir => nfs_dir,
# install kernel into a flavor specific subdir for distinction:
:tftpdir => tftpdir,
:arch => "--arch " + arch,
:arch => arch,
:hookdir => config['hookdir'] || "/etc/fai/flavors/#{f}/nfsroot-hooks/"
})
mode 0644
......
......@@ -22,28 +22,57 @@
# limitations under the License.
#
# additional source repos for package installation:
property :additional_sources, Array
# architecture eg. 'amd64'
property :arch, String
# codename eg. woody
property :codename, String, default: node['lsb']['codename']
# the URL the installer pulls its config from:
property :config_source, String,
default: (node['fai']['config_source'] ||
"nfs://#{node['ipaddress']}:#{node['fai']['configdir']}")
default: node['fai']['config_source']
property :additional_sources, Array
property :arch, String
property :codename, String
# the location of the Debian repository
property :debmirror_url, String, default: node['fai']['debmirror_url']
# dir for installing nfsroot_hooks that are executed during nfsroot creation
property :hook_dir, String
# install recommended packages?
property :install_recommends, [TrueClass, FalseClass],
default: node['fai']['install_recommends']
# install suggested packages?
property :install_suggests, [TrueClass, FalseClass],
default: node['fai']['install_suggests']
property :pkgs, Array
property :tftpdir, String
# the directory that holds the FAI config
property :nfsroot_config_dir, [String, NilClass]
# the base directory of the installer chroot
property :nfsroot_dir, [String, NilClass]
# list of packages to be installed into the installer nfsroot
property :pkgs, Array, default: []
# the directory kernel and initrs are copied to during installer creation
property :tftpdir, String
default_action :create
action :create do
nfsroot_config_dir = new_resource.nfsroot_config_dir ||
"/etc/fai/flavors/#{new_resource.name}"
nfsroot_dir = new_resource.nfsroot_dir ||
"/srv/fai/nfsroot-#{new_resource.name}"
# apply some defaults:
nfsroot_config = 'nfsroot.conf'
configdir = "/etc/fai/flavors/#{new_resource.name}"
# new_resource.name is something like squeeze-amd64
codename = new_resource.codename || new_resource.name.split("-")[0]
......@@ -51,8 +80,6 @@ action :create do
# FIXME: handle flavors like "codename-arch-bla-blubb"
suffix = (new_resource.name.split("-")[2..-1] || []).join('_')
nfs_dir = "/srv/fai/nfsroot-#{new_resource.name}"
if new_resource.tftpdir
tftpdir = new_resource.tftpdir
else
......@@ -64,36 +91,37 @@ action :create do
#
# create the config in /etc/fai/flavors:
#
directory configdir do
directory nfsroot_config_dir do
action :create
end
directory "#{configdir}/apt" do
directory "#{nfsroot_config_dir}/apt" do
action :create
end
template "#{configdir}/fai.conf" do
template "#{nfsroot_config_dir}/fai.conf" do
source "fai.conf.erb"
variables(config_src: new_resource.fai_config_source)
variables(config_src: new_resource.config_source)
mode 0o0644
end
template "#{configdir}/#{nfsroot_config}" do
template "#{nfsroot_config_dir}/#{nfsroot_config}" do
source "make-fai-nfsroot.conf.erb"
variables(
config_src: new_resource.fai_config_source,
config_src: new_resource.config_source,
codename: codename,
debmirror_url: new_resource.debmirror_url,
nfsdir: nfs_dir,
nfsdir: nfsroot_dir,
# install kernel into a flavor specific subdir for distinction:
tftpdir: tftpdir,
arch: "--arch #{arch}",
hookdir: new_resource.hookdir || "/etc/fai/flavors/#{new_resource.name}/nfsroot-hooks/"
arch: arch,
hookdir: new_resource.hook_dir ||
"/etc/fai/flavors/#{new_resource.name}/nfsroot-hooks/"
)
mode 0o0644
end
template "#{configdir}/apt/sources.list" do
template "#{nfsroot_config_dir}/apt/sources.list" do
source "fai_sources.list.erb"
variables(
codename: codename,
......@@ -103,7 +131,7 @@ action :create do
mode 0o0644
end
template "#{configdir}/apt/apt.conf" do
template "#{nfsroot_config_dir}/apt/apt.conf" do
source "fai_apt.conf.erb"
variables(
install_recommends: new_resource.install_recommends,
......@@ -111,13 +139,13 @@ action :create do
)
end
link "#{configdir}/live.conf" do
link "#{nfsroot_config_dir}/live.conf" do
to '/etc/fai/live.conf'
end
pkgs = new_resource.pkgs + node['fai']['common_extra_pkgs']
template "#{configdir}/NFSROOT" do
template "#{nfsroot_config_dir}/NFSROOT" do
source "NFSROOT.erb"
variables(
extra_pkgs: pkgs,
......
# This file was created by Chef and the fai cookbook, do not edit manually
NFSROOT=<%= @nfsdir %>
TFTPROOT=<%= @tftpdir || '/srv/tftp/fai' %>
<%= "FAI_CONFIGDIR=#{@config_src}" if @config_src %>
NFSROOT_ETC_HOSTS="<%= node['ipaddress'] %> <%= node['fqdn'] %>"
FAI_DEBOOTSTRAP="<%= "#{@codename} #{@debmirror_url}" %>"
<% if node['fai']['root_pw_hash'] %>
FAI_ROOTPW='<%= node['fai']['root_pw_hash'] %>'
<% end %>
NFSROOT=<%= @nfsdir %>
TFTPROOT=<%= @tftpdir || '/srv/tftp/fai' %>
NFSROOT_HOOKS=<%= @hookdir %>
FAI_DEBOOTSTRAP_OPTS="--exclude=info --include=aptitude --include gnupg<%= " --arch #{@arch}" if @arch %>"
<%= "FAI_CONFIGDIR=#{@config_src}" if @config_src %>
NFSROOT_ETC_HOSTS="<%= node['ipaddress'] %> <%= node['fqdn'] %>"
<% if node["fai"]["root_ssh_pubkey"] -%>
SSH_IDENTITY=<%= node['fai']['root_ssh_pubkey'] %>
<% end %>
FAI_DEBOOTSTRAP_OPTS="--exclude=info --include=aptitude --include gnupg <%= @arch %>"
NFSROOT_HOOKS=<%= @hookdir %>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment