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
Nounous
Ansible
Commits
5df14515
Verified
Commit
5df14515
authored
Oct 22, 2021
by
Benjamin Graillot
Committed by
ynerant
Apr 04, 2022
Browse files
[dns-authoritative] Use ldap instead of re2oapi
parent
37696b96
Changes
2
Hide whitespace changes
Inline
Side-by-side
lookup_plugins/ldap.py
View file @
5df14515
...
...
@@ -136,6 +136,18 @@ class LookupModule(LookupBase):
result
=
[
ip
.
decode
(
'utf-8'
)
for
dn
,
entry
in
result
[
1
]
for
ip
in
entry
[
'ipHostNumber'
]
if
ipaddress
.
ip_address
(
ip
.
decode
(
'utf-8'
))
in
subnet
]
return
result
def
zones_new
(
self
):
search_dn
=
f
'ou=dns,
{
self
.
base_dn
}
'
query_id
=
self
.
base
.
search
(
search_dn
,
ldap
.
SCOPE_SUBTREE
,
"sOARecord=*"
)
query_result
=
self
.
base
.
result
(
query_id
)
result
=
[]
for
dn
,
entry
in
query_result
[
1
]:
result
.
append
(
'.'
.
join
([
dc
[
3
:]
for
dc
in
dn
[:
-
len
(
search_dn
)
-
1
].
split
(
','
)]))
return
result
def
zones_reverse
(
self
):
return
[
'76.230.185.in-addr.arpa'
,
'77.230.185.in-addr.arpa'
,
'78.230.185.in-addr.arpa'
,
'79.230.185.in-addr.arpa'
,
'0.0.7.0.c.0.a.2.ip6.arpa'
]
def
run
(
self
,
terms
,
variables
=
None
,
**
kwargs
):
if
terms
[
0
]
==
'query'
:
result
=
self
.
query
(
*
terms
[
1
:])
...
...
@@ -192,6 +204,10 @@ class LookupModule(LookupBase):
else
:
res
.
append
(
f
"
{
network
}
.crans.org"
)
result
=
res
elif
terms
[
0
]
==
'zones_new'
:
result
=
self
.
zones_new
()
elif
terms
[
0
]
==
'zones_reverse'
:
result
=
self
.
zones_reverse
()
elif
terms
[
0
]
==
'vlanid'
:
network
=
terms
[
1
]
query_id
=
self
.
base
.
search
(
f
"cn=
{
network
}
,ou=networks,
{
self
.
base_dn
}
"
,
ldap
.
SCOPE_BASE
,
"objectClass=ipNetwork"
)
...
...
plays/dns-authoritative.yml
View file @
5df14515
...
...
@@ -8,8 +8,8 @@
bind
:
masters
:
"
{{
query('ldap',
'role',
'dns-primary')
}}"
slaves
:
"
{{
query('ldap',
'role',
'dns-secondary')
}}"
zones
:
"
{{
(lookup('re2oapi',
'dnszones')
+
query('ldap',
'zones
'))
|
unique
}}"
reverse
:
"
{{
lookup('
re2o
ap
i
',
'
dns
reverse')
}}"
zones
:
"
{{
query('ldap',
'zones
_new'))
}}"
reverse
:
"
{{
lookup('
ld
ap',
'
zones_
reverse')
}}"
roles
:
-
bind-authoritative
...
...
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