Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grid5000
reference-repository
Commits
095e6cfd
Commit
095e6cfd
authored
Apr 26, 2016
by
Jérémie Gaidamour
Browse files
[dev] bindg5k: reverse dns + global-site.conf files
parent
b20b1824
Changes
3
Hide whitespace changes
Inline
Side-by-side
dev/puppet/bind.rb
View file @
095e6cfd
...
...
@@ -49,11 +49,38 @@ def print_entry(entry)
else
return
"
#{
range
}#{
hostname
}
IN A
#{
ip
}
"
end
end
# Loop over Grid'5000 sites
# Examples: reverse-64.16.172.db
# 96 IN PTR opensm.nancy.grid5000.fr.
# $GENERATE 1-95 $ IN PTR graphene-$.nancy.grid5000.fr.
# $GENERATE 1-4 ${8,0,d} IN PTR graphite-$-ib0.nancy.grid5000.fr.
def
print_reverse_entry
(
site_uid
,
entry
)
if
entry
[
:start
].
nil?
range
=
"
#{
entry
[
:ip
].
split
(
'.'
)[
4
]
}
"
hostshort
=
entry
[
:uid
]
elsif
entry
[
:start
]
==
entry
[
:end
]
range
=
"
#{
entry
[
:start
]
+
entry
[
:shift
]
}
"
hostshort
=
"
#{
entry
[
:uid
]
}
-
#{
entry
[
:start
]
}
"
# graoully-1
else
range
=
"$GENERATE
#{
entry
[
:start
]
}
-
#{
entry
[
:end
]
}
"
# $GENERATE 1-16
shift
=
(
entry
[
:shift
]
>
0
?
'${+'
+
entry
[
:shift
].
to_s
+
'}'
:
'$'
)
range
+=
shift
hostshort
=
"
#{
entry
[
:uid
]
}
-$"
# graoully-$
end
file
=
"
#{
entry
[
:ip
].
split
(
'.'
)[
0
..
2
].
reverse
.
join
(
'.'
)
}
"
# 70.16.172
if
entry
[
:cnamesuffix
].
nil?
hostname
=
entry
[
:hostsuffix
]
?
hostshort
+
entry
[
:hostsuffix
]
:
hostshort
# graoully-$-eth0
else
hostname
=
hostshort
+
entry
[
:cnamesuffix
]
end
return
[
"reverse-
#{
file
}
.db"
,
"
#{
range
}
IN PTR
#{
hostname
}
.
#{
site_uid
}
.grid5000.fr."
]
end
# Loop over Grid'5000 sites
refapi
[
"sites"
].
each
{
|
site_uid
,
site
|
next
if
site_uid
!=
'nancy'
...
...
@@ -185,17 +212,40 @@ refapi["sites"].each { |site_uid, site|
#
# Output
#
dns
=
[]
# output file for dns entries
reverse
=
{}
# one hash entry per reverse dns file
output
=
[]
entries
.
each
{
|
type
,
e
|
e
.
each
{
|
entry
|
output
<<
print_entry
(
entry
)
dns
<<
print_entry
(
entry
)
# DNS
output_file
,
txt_entry
=
print_reverse_entry
(
site_uid
,
entry
)
# Reverse DNS
reverse
[
output_file
]
||=
[]
reverse
[
output_file
]
<<
txt_entry
}
}
zones_dir
=
Pathname
(
"
#{
$output_dir
}
/modules/bindg5k/files/zones/
#{
site_uid
}
"
)
zones_dir
.
mkpath
()
# DNS (/modules/bindg5k/files/zones/nancy-clusters.db)
output_file
=
cluster_file
=
site_uid
+
'-clusters.db'
File
.
write
(
zones_dir
+
output_file
,
dns
.
join
(
"
\n
"
))
# Reverse DNS (/modules/bindg5k/files/zones/reverse-*db)
header
=
ERB
.
new
(
File
.
read
(
'templates/bind-header.erb'
)).
result
(
binding
)
reverse
.
each
{
|
output_file
,
output
|
File
.
write
(
zones_dir
+
output_file
,
header
+
output
.
join
(
"
\n
"
))
}
output_file
=
Pathname
(
"
#{
$output_dir
}
/modules/bindg5k/files/zones/
#{
site_uid
}
/
#{
site_uid
}
-clusters.db"
)
output_file
.
dirname
.
mkpath
()
File
.
write
(
output_file
,
output
.
join
(
"
\n
"
))
}
# each sites
# files/global/conf/global-nancy.conf
# files/site/conf/global-nancy.conf
[
'global'
,
'site'
].
each
{
|
dir
|
conf_dir
=
Pathname
(
"
#{
$output_dir
}
/modules/bindg5k/files/
#{
dir
}
/conf"
)
conf_dir
.
mkpath
()
global_file
=
ERB
.
new
(
File
.
read
(
'templates/bind-global-site.conf.erb'
)).
result
(
binding
)
File
.
write
(
conf_dir
+
"global-
#{
site_uid
}
.conf"
,
global_file
)
}
}
# each sites
dev/puppet/templates/bind-global-site.conf.erb
0 → 100644
View file @
095e6cfd
<%
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
).
each
{
|
file
|
next
unless
/.*.db$/
.
match
(
file
)
next
if
file
==
"
#{
site_uid
}
-clusters.db"
# This file should be included in <site_uid>.db
comment
=
''
zone
=
''
if
file
==
"
#{
site_uid
}
.db"
zone
=
"
#{
site_uid
}
.grid5000.fr"
elsif
/^reverse-(.*).db$/
.
match
(
file
)
zone
=
"
#{
$1
}
.in-addr.arpa"
comment
=
'// The following entry was manually added'
if
!
reverse
.
keys
.
include?
(
file
)
else
puts
"Error: unkown zone for '
#{
file
}
' in '
#{
zones_dir
}
'"
next
end
%>
<%=
comment
%>
zone "
<%=
zone
%>
" {
type
<%=
type
%>
;
file "/etc/bind/zones/
<%=
site_uid
%>
/
<%=
file
%>
";
<%=
type
==
'slave'
?
'masters { master-ns-global; };'
:
''
%>
};
<%
}
%>
dev/puppet/templates/bind-header.erb
0 → 100644
View file @
095e6cfd
$TTL 3h
@ IN SOA dns.grid5000.fr. nsmaster.dns.grid5000.fr. (
<%=
Time
.
new
().
strftime
(
"%Y%m%d"
)
%>
00 ; serial (YYYYMMDDSS)
4h ; refresh
1h ; retry
4w ; expire
1h) ; negative caching
@ IN NS dns.grid5000.fr.
@ MX 10 mail.nancy.grid5000.fr.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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