Commit 0fd40aeb authored by Christopher Huhn's avatar Christopher Huhn
Browse files

Transform fai config setup into a custom resource

parent ea6a4543
Pipeline #2423 failed with stages
in 1 minute and 28 seconds
#
# Cookbook Name:: fai
# Resource:: fai_config
#
# Copyright 2012-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
#
# 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.
#
property :config_source. String,
default: (node['fai']['config_source'] || "nfs://#{node['ipaddress']}:#{node['fai']['configdir']}")
property :additional_sources, Array
property :arch. String
property :codename, String
property :debmirror_url, String, default: node['fai']['debmirror_url']
property :install_recommends, [TrueClass, FalseClass], default: node['fai']['install_recommends']
property :install_suggests, [TrueClass, FalseClass], default: node['fai']['install_suggests']
property :pkgs, Array
property :tftpdir, String
default_action :create
action :create do
# 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]
arch = new_resource.arch || new_resource.name.split("-")[1]
# 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
tftpdir = "/srv/tftp/#{codename}/#{arch}" +
( (suffix.empty?) ? '' : "/#{suffix}" ) +
"/fai#{node['debian']['packages']['fai-server']['version']}/"
end
#
# create the config in /etc/fai/flavors:
#
directory configdir do
action :create
end
directory "#{configdir}/apt" do
action :create
end
template "#{configdir}/fai.conf" do
source "fai.conf.erb"
variables(config_src: new_resource.fai_config_source)
mode 0644
end
template "#{configdir}/#{nfsroot_config}" do
source "make-fai-nfsroot.conf.erb"
variables(
config_src: new_resource.fai_config_source,
codename: codename,
debmirror_url: new_resource.debmirror_url,
nfsdir: nfs_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/"
)
mode 0644
end
template "#{configdir}/apt/sources.list" do
source "fai_sources.list.erb"
variables(
codename: codename,
debmirror_url: new_resource.debmirror_url,
additional_sources: new_resource.additional_sources
)
mode 0644
end
template "#{configdir}/apt/apt.conf" do
source "fai_apt.conf.erb"
variables(
install_recommends: new_resource.install_recommends,
install_suggests: new_resource.install_suggests
)
end
link "#{configdir}/live.conf" do
to '/etc/fai/live.conf'
end
pkgs = new_resource.pkgs + node['fai']['common_extra_pkgs']
template "#{configdir}/NFSROOT" do
source "NFSROOT.erb"
variables(
extra_pkgs: pkgs,
install_action: nil
)
mode 0644
end
end
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