Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grid5000
reference-repository
Commits
30a31b24
Commit
30a31b24
authored
Feb 01, 2018
by
Simon Delamare
Committed by
simfu
Jul 12, 2018
Browse files
[generators] Update bind generator for puppet4
parent
2adae387
Changes
3
Hide whitespace changes
Inline
Side-by-side
generators/puppet/bindg5k.rb
View file @
30a31b24
...
...
@@ -22,14 +22,14 @@ refapi = load_yaml_file_hierarchy(File.expand_path(input_data_dir, File.dirname(
$options
=
{}
$options
[
:sites
]
=
%w{grenoble lille luxembourg lyon nancy nantes rennes sophia}
$options
[
:output_dir
]
=
"/tmp/puppet
-repo
"
$options
[
:output_dir
]
=
"/tmp/puppet"
$options
[
:verbose
]
=
false
OptionParser
.
new
do
|
opts
|
opts
.
banner
=
"Usage: bindg5k.rb [options]"
opts
.
separator
""
opts
.
separator
"Example: ruby bindg5k.rb -s nancy -o /tmp/puppet
-repo
"
opts
.
separator
"Example: ruby bindg5k.rb -s nancy -o /tmp/puppet"
opts
.
on
(
'-o'
,
'--output-dir dir'
,
String
,
'Select the puppet repo path'
,
"Default: "
+
$options
[
:output_dir
])
do
|
d
|
$options
[
:output_dir
]
=
d
...
...
@@ -448,13 +448,18 @@ def get_orphan_reverse_manual_zones(zones_dir, site_uid, site)
return
zones
end
def
write_global_site_conf
(
site_uid
,
dest_dir
,
zones_dir
)
[
'global'
,
'site'
].
each
{
|
dir
|
conf_file
=
File
.
join
(
dest_dir
,
"
#{
dir
}
/conf"
,
"global-
#{
site_uid
}
.conf"
)
def
write_site_conf
(
site_uid
,
dest_dir
,
zones_dir
)
conf_file
=
File
.
join
(
dest_dir
,
"
#{
site_uid
}
-zones.conf"
)
FileUtils
.
mkdir_p
(
File
.
dirname
(
conf_file
))
conf_content
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/bind-global-site.conf.erb'
,
File
.
dirname
(
__FILE__
)))).
result
(
binding
)
conf_content
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/bind-site.conf.erb'
,
File
.
dirname
(
__FILE__
)))).
result
(
binding
)
File
.
write
(
conf_file
,
conf_content
)
end
def
write_site_local_conf
(
site_uid
,
dest_dir
,
zones_dir
)
conf_file
=
File
.
join
(
dest_dir
,
"
#{
site_uid
}
-localzones.conf"
)
FileUtils
.
mkdir_p
(
File
.
dirname
(
conf_file
))
conf_content
=
ERB
.
new
(
File
.
read
(
File
.
expand_path
(
'templates/bind-site-local.conf.erb'
,
File
.
dirname
(
__FILE__
)))).
result
(
binding
)
File
.
write
(
conf_file
,
conf_content
)
}
end
def
write_zone
(
zone
)
...
...
@@ -474,7 +479,7 @@ refapi["sites"].each { |site_uid, site|
next
unless
$options
[
:sites
].
include?
(
site_uid
)
dest_dir
=
"
#{
$options
[
:output_dir
]
}
/
modules/bindg5k
/files/"
dest_dir
=
"
#{
$options
[
:output_dir
]
}
/
platforms/production/modules/generated
/files/
bind/
"
zones_dir
=
File
.
join
(
dest_dir
,
"zones/
#{
site_uid
}
"
)
site_records
=
{}
...
...
@@ -590,6 +595,7 @@ refapi["sites"].each { |site_uid, site|
write_zone
(
zone
)
}
write_global_site_conf
(
site_uid
,
dest_dir
,
zones_dir
)
write_site_conf
(
site_uid
,
dest_dir
,
zones_dir
)
write_site_local_conf
(
site_uid
,
dest_dir
,
zones_dir
)
}
# each sites
generators/puppet/templates/bind-site-local.conf.erb
0 → 100644
View file @
30a31b24
<%
# List file in the directory instead of using the 'reverse' variable as some files might be set manually
Dir
.
entries
(
File
.
join
(
zones_dir
,
"local"
)).
sort
.
each
{
|
file
|
next
unless
/.*.db$/
.
match
(
file
)
comment
=
''
zone
=
''
if
file
==
"
#{
site_uid
}
.db"
zone
=
"
#{
site_uid
}
.grid5000.fr"
elsif
/^reverse-(.*).db$/
.
match
(
file
)
zone
=
"
#{
$1
}
.in-addr.arpa"
else
puts
"Error: unknown zone for '
#{
file
}
' in '
#{
zones_dir
}
'"
next
end
%>
zone "
<%=
zone
%>
" {
type master;
file "/etc/bind/zones/
<%=
site_uid
%>
/local/
<%=
file
%>
";
};
<%
}
%>
generators/puppet/templates/bind-
global-
site.conf.erb
→
generators/puppet/templates/bind-site.conf.erb
View file @
30a31b24
<%
if
dir
==
'global'
type
=
'master'
elsif
dir
==
'site'
type
=
'slave'
else
raise
"'dir' undefined"
end
# List file in the directory instead of using the 'reverse' variable as some files might be set manually
Dir
.
entries
(
zones_dir
).
sort
.
each
{
|
file
|
next
unless
/.*.db$/
.
match
(
file
)
...
...
@@ -27,8 +19,7 @@ Dir.entries(zones_dir).sort.each { |file|
end
%>
zone "
<%=
zone
%>
" {
type
<%=
type
%>
;
type
master
;
file "/etc/bind/zones/
<%=
site_uid
%>
/
<%=
file
%>
";
<%=
type
==
'slave'
?
'masters { master-ns-global; };'
:
''
%>
};
<%
}
%>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment