Commit 959e6e8b authored by Jérémie Gaidamour's avatar Jérémie Gaidamour

[dev] Added banner to the generated configuration files

also:
* moved configuration files to the puppet-repo
* simplified the Rakefile
* default output_dir is now /tmp/puppet-repo instead of output/
* added an example of console-password.yaml
* check if conf_dir exists
parent a2e850ee
......@@ -36,6 +36,20 @@ def write_yaml(filepath, data)
end
end
# prepend header
def add_header(output_file)
header_template = <<-eol
#
# This file was generated by reference-repository.git/generators/puppet/<%= File.basename($PROGRAM_NAME) %>
# Do not edit this file by hand. Your changes will be overwritten.
#
eol
header = ERB.new(header_template).result()
contents = File.read(output_file)
File.write(output_file, header + "\n" + contents)
end
# Extend Hash with helper methods needed to convert input data files to ruby Hash
class ::Hash
......
task :default => [:kadeployg5k, :conmang5k, :lanpowerg5k]
all_tasks = [:bindg5k, :conmang5k, :dhcpg5k, :kadeployg5k, :lanpowerg5k]
desc "Generate kadeployg5k configuration"
task :kadeployg5k do
ruby 'kadeployg5k.rb'
end
task :default => all_tasks
desc "Generate conmang5k configuration"
task :conmang5k do
ruby 'conmang5k.rb'
all_tasks.each { |t|
desc "Generate #{t} configuration"
task t do
ruby "#{t}.rb"
end
desc "Generate lanpowerg5k configuration"
task :lanpowerg5k do
ruby 'lanpowerg5k.rb'
end
\ No newline at end of file
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ require 'pathname'
require '../lib/input_loader'
refapi = load_yaml_file_hierarchy("../../input/grid5000/")
$output_dir = ENV['puppet_repo'] || 'output'
$output_dir = ENV['puppet_repo'] || '/tmp/puppet-repo'
# Create a dns entry
# $GENERATE 1-16 graoully-$-bmc IN A 172.17.70.$
......@@ -136,7 +136,7 @@ refapi["sites"].each { |site_uid, site|
network_adapters = {}
# Nodes
pp node_uid
#pp node_uid
node.fetch('network_adapters').each { |net_uid, net_hash|
network_adapters[net_uid] = {"ip" => net_hash["ip"], "mounted" => net_hash["mounted"]} #, "network_address" => net_hash["network_address"]}
}
......
# This is an EXAMPLE of input file for [conmang5k,lanpowerg5k].rb
---
grenoble:
adonis: login password
genepi: login password
edel: login password
lille:
chirloute: login password
chimint: login password
chinqchint: login password
luxembourg:
granduc: login password
petitprince: login password
lyon:
sagittaire: login password
taurus: login password
orion: login password
hercule: login password
nancy:
griffon: login password
graphene: login password
talc: login password
graphite: login password
graphique: login password
graoully: login password
grimoire: login password
grisou: login password
nantes:
econome: login password
reims:
stremi: login password
rennes:
parapide: login password
parapluie: login password
paranoia: login password
parasilo: login password
paravance: login password
ceph: login password
sophia:
sol: login password
suno: login password
uva: login password
uvb: login password
# This is an EXAMPLE of input file for [conmang5k,lanpowerg5k].rb
luxembourg:
petitprince:
lanpower:
......
# This is an EXAMPLE of input file for kadeployg5k.rb
---
grenoble:
adonis:
......
# This is an EXAMPLE of input file for kadeployg5k.rb
---
grenoble:
adonis:
......
......@@ -13,12 +13,14 @@ require 'pathname'
require '../lib/input_loader'
require '../lib/hash/hash.rb'
$output_dir = ENV['puppet_repo'] || 'output'
$output_dir = ENV['puppet_repo'] || '/tmp/puppet-repo'
$conf_dir = ENV['conf_dir'] || Pathname("#{$output_dir}/modules/lanpowerg5k/generators/")
raise("Error: #{$conf_dir} does not exist. The environment variables are not set propertly") unless Pathname($conf_dir).exist?
# Input
refapi = load_yaml_file_hierarchy("../../input/grid5000/")
config = YAML::load_file('./conf/console.yaml')
credentials = YAML::load_file('./conf/console-password.yaml')
config = YAML::load_file($conf_dir + 'console.yaml')
credentials = YAML::load_file($conf_dir + 'console-password.yaml')
# Apply ERB template and save result to file
def write_conman_file(site_uid, site_refapi, site_config, site_credentials)
......
......@@ -11,7 +11,7 @@ require 'pathname'
require '../lib/input_loader'
global_hash = load_yaml_file_hierarchy("../../input/grid5000/")
$output_dir = ENV['puppet_repo'] || 'output'
$output_dir = ENV['puppet_repo'] || '/tmp/puppet-repo'
# Get the mac and ip of a node. Throw exception if error.
def get_network_info(node_hash, network_interface)
......
......@@ -7,7 +7,7 @@ end
# This script generates:
# - kadeployg5k/files/<site_uid>/server_conf[_dev]/clusters.conf from input/
# - kadeployg5k/files/<site_uid>/server_conf[_dev]/<cluster_uid>-cluster.conf from conf/kadeployg5k.yaml and template/kadeployg5k.yaml.Erb
# - kadeployg5k/files/<site_uid>/server_conf[_dev]/<cluster_uid>-cluster.conf from kadeployg5k[-dev].yaml and template/kadeployg5k.yaml.erb
require 'pp'
require 'erb'
......@@ -16,7 +16,9 @@ require '../lib/input_loader'
require '../lib/hash/hash.rb'
global_hash = load_yaml_file_hierarchy("../../input/grid5000/")
$output_dir = ENV['puppet_repo'] || 'output'
$output_dir = ENV['puppet_repo'] || '/tmp/puppet-repo'
$conf_dir = ENV['conf_dir'] || Pathname("#{$output_dir}/modules/lanpowerg5k/generators/")
raise("Error: #{$conf_dir} does not exist. The environment variables are not set propertly") unless Pathname($conf_dir).exist?
# Compute cluster prefix
# input: cluster_list = ['graoully', 'graphene', 'griffon', ...]
......@@ -122,14 +124,15 @@ end
output_file = Pathname("#{$output_dir}/modules/kadeployg5k/files/#{site_uid}/server_conf#{suffix.tr('-', '_')}/clusters.conf")
output_file.dirname.mkpath()
write_yaml(output_file, clusters_conf)
add_header(output_file)
#
# Generate <cluster_uid>-cluster.conf files
#
# Load 'conf/kadeployg5k.yaml' data and fill up the kadeployg5k.conf.erb template for each cluster
conf = YAML::load(ERB.new(File.read("./conf/kadeployg5k#{suffix}.yaml")).result(binding))
conf = YAML::load(ERB.new(File.read($conf_dir + "kadeployg5k#{suffix}.yaml")).result(binding))
site['clusters'].each { |cluster_uid, cluster|
......
......@@ -13,10 +13,12 @@ require 'pathname'
require '../lib/input_loader'
require '../lib/hash/hash.rb'
$output_dir = ENV['puppet_repo'] || 'output'
$output_dir = ENV['puppet_repo'] || '/tmp/puppet-repo'
$conf_dir = ENV['conf_dir'] || Pathname("#{$output_dir}/modules/lanpowerg5k/generators/")
raise("Error: #{$conf_dir} does not exist. The environment variables are not set propertly") unless Pathname($conf_dir).exist?
config = YAML::load_file('conf/console.yaml')
credentials = YAML::load_file('conf/console-password.yaml')
config = YAML::load_file($conf_dir + 'console.yaml')
credentials = YAML::load_file($conf_dir + 'console-password.yaml')
refapi = load_yaml_file_hierarchy("../../input/grid5000/")
refapi['sites'].each { |site_uid, site_refapi|
......@@ -69,5 +71,6 @@ refapi['sites'].each { |site_uid, site_refapi|
output_file = Pathname("#{$output_dir}/modules/lanpowerg5k/files/#{site_uid}/lanpower.yaml")
output_file.dirname.mkpath()
write_yaml(output_file, h)
add_header(output_file)
}
;
; This file was generated by reference-repository.git/generators/puppet/<%= File.basename($PROGRAM_NAME) %>
; Do not edit this file by hand. Your changes will be overwritten.
;
<%
if dir == 'global'
type = 'master'
......
;
; This file was generated by reference-repository.git/generators/puppet/<%= File.basename($PROGRAM_NAME) %>
; Do not edit this file by hand. Your changes will be overwritten.
;
$TTL 3h
@ IN SOA dns.grid5000.fr. nsmaster.dns.grid5000.fr. (
<%= Time.new().strftime("%Y%m%d") %>00 ; serial (YYYYMMDDSS)
......
#
# This file was generated by reference-repository.git/generators/puppet/<%= File.basename($PROGRAM_NAME) %>
# Do not edit this file by hand. Your changes will be overwritten.
#
server logfile="/var/log/conman.log"
<%
......
# INSTALLED BY PUPPET, GENERATED by reference-repo generators
# Module:: dhcpg5k
# File:: puppet:///modules/dhcpg5k/<%= data.fetch('site_uid') %>/dhcpd.conf.d/<%= data.fetch('filename') %>
#
# This file was generated by reference-repository.git/generators/puppet/<%= File.basename($PROGRAM_NAME) %>
# Do not edit this file by hand. Your changes will be overwritten.
#
<%
site_uid = data.fetch('site_uid')
......
#
# This file was generated by reference-repository.git/generators/puppet/<%= File.basename($PROGRAM_NAME) %>
# Do not edit this file by hand. Your changes will be overwritten.
#
---
partitioning:
block_device: /dev/sda
......
Markdown is supported
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