Commit 23b2aeb2 authored by Christopher Huhn's avatar Christopher Huhn
Browse files

Introduce a flag to turn off nfsroot handling by the cookbook

parent 54ea01ac
......@@ -36,6 +36,10 @@ default[:fai][:root_pw_hash] = '$1$kBnWcO.E$djxB128U7dMkrltJHPf6d1' # "f
# install the sample config:
default[:fai][:setup_default] = false
# set this to false to keep the FAI cookbook from
# creating and updating nfsroots:
default_unless['fai']['handle_nfsroots'] = true
# this value will be set by the Debian ohai plugin from sys cookbook
# as a default we will define it as empty
default[:debian][:packages]['fai-server'][:version] = ''
......@@ -2,7 +2,7 @@
# Cookbook Name:: fai
# Recipe:: default
#
# Copyright 2011, GSI Darmstadt
# Copyright 2011-2017, GSI Darmstadt
#
# All rights reserved - Do Not Redistribute
#
......@@ -11,11 +11,13 @@
include_recipe "nfs::server"
# install required packages
package "fai-server"
package "fai-server" do
notifies :reload, 'ohai[Dpkg]', :immediate
end
#package fai-quickstart ???
ohai 'Dpkg' do
action :reload
action :nothing
end
# fallback to admit access to everybody if not specified
......@@ -51,18 +53,13 @@ if node.fai.configdir
end
# There have been some changes to FAI v4, which is shipped on Wheezy
nfsroot_config = "make-fai-nfsroot.conf"
if (node.lsb.codename == "wheezy") or (node.lsb.codename == "jessie")
nfsroot_config = "nfsroot.conf"
end
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}"
unless node['fai']['config_source'] == nil
fai_config_source = "nfs://#{node['ipaddress']}:#{node['fai']['configdir']}"
else
fai_config_source = node.fai.config_source
fai_config_source = node['fai']['config_source']
end
#setup fai config(s)
......@@ -117,12 +114,11 @@ end
# source "file:///etc/apt/sources.list"
#end
template "/etc/fai/NFSROOT" do
source "NFSROOT.erb"
variables({
:extra_pkgs => node.fai.common_extra_pkgs
})
variables(
:extra_pkgs => node['fai']['common_extra_pkgs']
)
mode 0644
notifies :run, "execute[update-nfsroot]" #, :immediately ???
end
......@@ -131,6 +127,7 @@ end
execute "update-nfsroot" do
command "fai-make-nfsroot -k"
action :nothing
only_if { Dir.exist?('/srv/fai/nfsroot') && node['fai']['handle_nfsroots'] }
end
# TODO: add cron job for periodic updating of nfsroot
......@@ -154,8 +151,8 @@ if node.fai.setup_default
creates "/srv/fai/nfsroot"
notifies :restart, "service[#{node['nfs']['service']['server']}]"
action :run
end
only_if { node['fai']['handle_nfsroots'] }
end
end
node[:fai][:clients].each do |client|
......
#
# Cookbook Name:: fai
# Recipe:: flavors
#
# Copyright 2011-2016, GSI Darmstadt
#
# All rights reserved - Do Not Redistribute
#
# recipe for configuring multiple FAI nfsroots on a single server in parallel
#
directory '/etc/fai/flavors' do
action :create
end
# There have been some changes to FAI v4, which is shipped on Wheezy
nfsroot_config = "make-fai-nfsroot.conf"
nfsroot_cmd = "make-fai-nfsroot"
if (node.lsb.codename == "wheezy") or (node.lsb.codename == "jessie")
nfsroot_config = "nfsroot.conf"
nfsroot_cmd = "fai-make-nfsroot"
end
nfsroot_config = 'nfsroot.conf'
nfsroot_cmd = 'fai-make-nfsroot'
# If fai.config_source is not set, fall back to a default nfs URL
unless node.fai.config_source == nil
unless node['fai']['config_source'] == nil
fai_config_source = "nfs://#{node.ipaddress}:#{node.fai.configdir}"
else
fai_config_source = node.fai.config_source
fai_config_source = node['fai']['config_source']
end
......@@ -29,11 +33,11 @@ node.fai.flavors.each do |f, config|
arch = config['arch'] || f.split("-")[1]
nfs_dir = "/srv/fai/nfsroot-#{f}"
directory "#{configdir}" do
action :create
end
directory "#{configdir}/apt" do
action :create
end
......@@ -46,7 +50,7 @@ node.fai.flavors.each do |f, config|
mode 0644
end
tftpdir = "/srv/tftp/#{codename}/#{arch}" +
tftpdir = "/srv/tftp/#{codename}/#{arch}" +
"/fai#{node[:debian][:packages]['fai-server'][:version]}/"
directory tftpdir do
......@@ -109,14 +113,13 @@ node.fai.flavors.each do |f, config|
action :nothing
# don't abort if nfsroot upgrades fail:
ignore_failure true
only_if do
File.exists? nfs_dir
end
only_if { File.exist?(nfs_dir) && node['fai']['handle_nfsroots'] }
end
execute "fai-setup -C #{configdir}" do
action :run
creates nfs_dir
only_if { node['fai']['handle_nfsroots'] }
end
node[:fai][:clients].each do |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