Commit 39c76222 authored by Christopher Huhn's avatar Christopher Huhn
Browse files

Reorder resources and skip early if 'config_only' applies

parent e4568fdb
......@@ -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.9.2"
version "0.9.3"
depends "nfs"
source_url 'https://git.gsi.de/chef/cookbooks/fai'
......
......@@ -26,14 +26,36 @@ end
node['fai']['flavors'].each do |f, config|
config = config.to_h
# apply some defaults:
configdir = "/etc/fai/flavors/#{f}"
# 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"
suffix = (f.split("-")[2..-1] || []).join('_')
nfs_dir = "/srv/fai/nfsroot-#{f}"
if config['tftpdir']
tftpdir = config['tftpdir']
else
tftpdir = "/srv/tftp/#{codename}/#{arch}" +
( (suffix.empty?) ? '' : "/#{suffix}" ) +
"/fai#{node['debian']['packages']['fai-server']['version']}/"
end
# only create config in /etc/fai/flavors or also
# create the installer nfsroot with fai-make-nfsroot?
config['config_only'] ||= (node['fai']['handle_nfsroots'] == false)
#
# create the config in /etc/fai/flavors:
#
directory configdir do
action :create
end
......@@ -50,17 +72,6 @@ node['fai']['flavors'].each do |f, config|
mode 0644
end
if config['tftpdir']
tftpdir = config['tftpdir']
else
tftpdir = "/srv/tftp/#{codename}/#{arch}" +
"/fai#{node['debian']['packages']['fai-server']['version']}/"
end
directory tftpdir do
recursive true
end
template "#{configdir}/#{nfsroot_config}" do
source "make-fai-nfsroot.conf.erb"
variables({
......@@ -89,11 +100,15 @@ node['fai']['flavors'].each do |f, config|
template "#{configdir}/apt/apt.conf" do
source "fai_apt.conf.erb"
variables({
# we cannot simply use 'or' here, as we are dealing with booleans ...
:install_recommends => config.has_key?('install_recommends')?config['install_recommends']:node['fai']['install_recommends'],
:install_suggests => config.has_key?('install_suggests')?config['install_suggests']:node['fai']['install_suggests']
})
variables(
# we cannot simply use 'or' here, as we are dealing with booleans ...
install_recommends: config.has_key?('install_recommends') ?
config['install_recommends'] :
node['fai']['install_recommends'],
install_suggests: config.has_key?('install_suggests') ?
config['install_suggests'] :
node['fai']['install_suggests']
)
end
link "#{configdir}/live.conf" do
......@@ -107,27 +122,49 @@ node['fai']['flavors'].each do |f, config|
source "NFSROOT.erb"
variables(
:extra_pkgs => pkgs,
:install_action => ((codename == 'stretch')?'install':nil) #' stupid emacs
:install_action => ((codename == 'stretch') ? 'install' : nil)
)
mode 0644
notifies :run, "execute[update-#{f}-nfsroot]"
end
#
# update nfsroot
#
execute "update-#{f}-nfsroot" do
command "#{nfsroot_cmd} -k -C #{configdir}"
action :nothing
# don't abort if nfsroot upgrades fail:
ignore_failure true
only_if { File.exist?(nfs_dir) && node['fai']['handle_nfsroots'] }
only_if { File.exist?(nfs_dir) }
# resource has to be defined but will be skipped:
not_if { config['config_only'] }
end
#
# or create nfsroot:
#
# -l option is required for fai-cd with FAI <= 4.*
execute "fai-setup -C #{configdir} #{'-l' if config['liveboot']}" do
action :run
creates nfs_dir
only_if { node['fai']['handle_nfsroots'] }
# resource has to be defined but will be skipped:
not_if { config['config_only'] }
end
# skip TFTP setup
next if config['config_only']
#
# set up tftp dir
#
directory tftpdir do
recursive true
end
#
# add NFS entry:
#
node['fai']['clients'].each do |client|
nfs_export nfs_dir do
network client
......
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