Don't use cloud_name to determine the zone name for DNS

We don't want to use the cloud_name because we do not know what
the cloud name is when we do a stack delete.  The new code
calculates the zone name the same way that the code that
deletes dns entries does.

Change-Id: I4c84c006a4ea9a5c51230fdeff9af000b4f703e4
This commit is contained in:
Grzegorz Grasza 2020-04-07 12:52:51 +02:00
parent bd752a79c2
commit b92b9b81ec
3 changed files with 19 additions and 17 deletions

View File

@ -192,9 +192,11 @@ def test_services(host, service, subhost):
('172.16.0.195', 'overcloud-novacompute-0.tenant'),
('192.168.24.128', 'overcloud-novacompute-0.ctlplane')])
def test_dns(host, ip, name):
name += '.ooo.test'
record_name, zone_name = name.split('.', 1)
result = host.check_output(
'ipa dnsrecord-find ooo.test --name={}'.format(
name))
'ipa dnsrecord-find {} --name={}'.format(
zone_name, record_name))
assert 'record: {}'.format(ip) in result

View File

@ -15,15 +15,27 @@
# under the License.
- name: set record_value and record_name
- name: set forward dns record values
set_fact:
record_value: "{{ item.split()[0] }}"
record_name: "{{ item.split()[1]|regex_replace('(.*).' + cloud_domain + '$', '\\1') }}"
record_name: "{{ item.split()[1].split('.', 1)[0] }}"
zone_name: "{{ item.split()[1].split('.', 1)[1] }}"
- name: set record type
set_fact:
record_type: "{{ 'A' if record_value| ipv4 else 'AAAA' }}"
- name: add dns zone
ipa_dnszone:
zone_name: "{{ zone_name }}"
- name: add forward dns record
ipa_dnsrecord:
zone_name: "{{ zone_name }}"
record_name: "{{ record_name }}"
record_type: "{{ record_type }}"
record_value: "{{ record_value }}"
- name: get reverse record data
set_fact:
reverse_addr: "{{ record_value | ipaddr('revdns') }}"
@ -40,13 +52,6 @@
reverse_record_name: "{{ '.'.join(reverse_addr.split('.', tripleo_ipa_ptr_zone_split_ipv6|int)[:-1]) }}"
when: record_type == 'AAAA'
- name: add forward dns record
ipa_dnsrecord:
zone_name: "{{ cloud_domain }}"
record_name: "{{ record_name }}"
record_type: "{{ record_type }}"
record_value: "{{ record_value }}"
- name: add reverse record dns zone
ipa_dnszone:
zone_name: "{{ reverse_record_zone }}"
@ -59,7 +64,7 @@
ipa_dnsrecord:
zone_name: "{{ reverse_record_zone }}"
record_name: "{{ reverse_record_name }}"
record_value: "{{ record_name }}.{{ cloud_domain }}."
record_value: "{{ record_name }}.{{ zone_name }}."
record_type: "PTR"
register: reverse_record_result
failed_when:

View File

@ -17,14 +17,9 @@
# This role adds a host entries to FreeIPA, as defined in the host_entry variable.
#
# The following variables are required:
# - cloud_domain (Base domain, eg. example.com)
# - host_entry (host entries string, in a format similar to /etc/hosts)
- name: add cloud_domain dns zone
ipa_dnszone:
zone_name: "{{ cloud_domain }}"
- name: add dns records
include_tasks:
file: dns.yaml