mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipatests: Add records for all hosts in master's domain
All the hosts in the domain have IPA master set as their only nameserver. However, the IPA master does not create records for these machines by default. This is not an big issue for clients or replicas, since those records do get created in other ways, but external hosts using their internal hostnames will not resolve. Adds an A record for each host in master's domain. https://fedorahosted.org/freeipa/ticket/4130 Reviewed-By: Petr Viktorin <pviktori@redhat.com>
This commit is contained in:
parent
03d093d793
commit
baf9b4c02a
@ -213,6 +213,24 @@ class TaskRunner(object):
|
||||
help='Server that serves as a time source')
|
||||
subparser.set_defaults(func=self.sync_time)
|
||||
|
||||
subparser = subparsers.add_parser(
|
||||
'add-a-records-in-master-domain',
|
||||
help='Adds A records to the IPA master for all the hosts in the '
|
||||
'master domain.')
|
||||
subparser.add_argument('master', type=str,
|
||||
help='IPA master to add records on')
|
||||
subparser.set_defaults(
|
||||
func=self.add_a_records_for_hosts_in_master_domain)
|
||||
|
||||
subparser = subparsers.add_parser(
|
||||
'add-a-record',
|
||||
help='Adds A record for the host to the IPA master')
|
||||
subparser.add_argument('master', type=str,
|
||||
help='IPA master to add record on')
|
||||
subparser.add_argument('host', type=str,
|
||||
help='Host whose record should be added')
|
||||
subparser.set_defaults(func=self.add_a_record)
|
||||
|
||||
return parser
|
||||
|
||||
def main(self, argv):
|
||||
@ -397,5 +415,14 @@ class TaskRunner(object):
|
||||
server = self.get_host(args.server)
|
||||
tasks.sync_time(host, server)
|
||||
|
||||
def add_a_records_for_hosts_in_master_domain(self, args):
|
||||
master = self.get_host(args.master, default=args.domain.master)
|
||||
tasks.add_a_records_for_hosts_in_master_domain(master)
|
||||
|
||||
def add_a_record(self, args):
|
||||
master = self.get_host(args.master, default=args.domain.master)
|
||||
host = self.get_host(args.host)
|
||||
tasks.add_a_record(master, host)
|
||||
|
||||
if __name__ == '__main__':
|
||||
exit(TaskRunner().main(sys.argv[1:]))
|
||||
|
@ -147,6 +147,13 @@ Clears SSSD cache by removing the cache files. Restarts SSSD.
|
||||
Syncs the time with the remote server. Please note that this function leaves
|
||||
ntpd stopped.
|
||||
|
||||
.TP
|
||||
\fBipa\-test\-task add\-a\-records\-in\-master\-domain MASTER\fR
|
||||
Adds A records to the IPA master for all the hosts in the master domain.
|
||||
|
||||
.TP
|
||||
\fBipa\-test\-task add\-a\-record MASTER HOST\fR
|
||||
Adds an A record for the host to the IPA master.
|
||||
|
||||
.SH "EXIT STATUS"
|
||||
0 if the command was successful
|
||||
|
@ -572,6 +572,9 @@ def install_topo(topo, master, replicas, clients,
|
||||
installed = {master}
|
||||
if not skip_master:
|
||||
install_master(master)
|
||||
|
||||
add_a_records_for_hosts_in_master_domain(master)
|
||||
|
||||
for parent, child in get_topo(topo)(master, replicas):
|
||||
if child in installed:
|
||||
log.info('Connecting replica %s to %s' % (parent, child))
|
||||
@ -632,3 +635,28 @@ def wait_for_replication(ldap, timeout=30):
|
||||
break
|
||||
else:
|
||||
log.error('Giving up wait for replication to finish')
|
||||
|
||||
|
||||
def add_a_records_for_hosts_in_master_domain(master):
|
||||
for host in master.domain.hosts:
|
||||
# We don't need to take care of the zone creation since it is master
|
||||
# domain
|
||||
add_a_record(master, host)
|
||||
|
||||
|
||||
def add_a_record(master, host):
|
||||
# Find out if the record is already there
|
||||
cmd = master.run_command(['ipa',
|
||||
'dnsrecord-find',
|
||||
master.domain.name,
|
||||
host.hostname,
|
||||
'--a-rec', host.ip],
|
||||
raiseonerr=False)
|
||||
|
||||
# If not, add it
|
||||
if cmd.returncode != 0:
|
||||
master.run_command(['ipa',
|
||||
'dnsrecord-add',
|
||||
master.domain.name,
|
||||
host.hostname,
|
||||
'--a-rec', host.ip])
|
||||
|
Loading…
Reference in New Issue
Block a user