This repository has been archived by the owner on Nov 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update CASL to use nsupdate for DNS records (#48)
* Updated to use nsupdate for DNS records * Updated formatting of dict * Updating descriptive text * Support for external DNS config * Upgrading jinja2 to work correctly with latest templates * Latest update for nsupdate * Updated to use nsupdate for DNS records * Updated formatting of dict * Updating descriptive text * Support for external DNS config * Latest update for nsupdate * Updated to support external public/private DNS server(s) * Updated DNS server handling * Updated DNS server handling * Updated DNS server handling * Eliminated the from the sample inventories * Updated sample inventory to point to 2 separate DNS servers for private/public * Playbook clean-up * Adding 'python-dns' * splitting subscription manager calls to allow for a clean pre-install playbook
- Loading branch information
Showing
31 changed files
with
338 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
inventory/sample.casl.example.com.d/inventory/group_vars/OSEv3.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,3 @@ | |
delegate_to: localhost | ||
roles: | ||
- role: dns-server | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
--- | ||
|
||
named_config_views: | ||
- name: "casl" | ||
- name: "casl-private" | ||
zone: | ||
- "dns_domain": "casl.example.com" | ||
- "dns_domain": "private.example.com" | ||
- name: "casl-public" | ||
zone: | ||
- "dns_domain": "public.example.com" | ||
forwarder: | ||
- "8.8.8.8" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
|
||
- name: "Generate list of private A records" | ||
set_fact: | ||
private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'hostname': hostvars[item]['ansible_hostname'], 'ip': hostvars[item]['openstack']['private_v4'] } ] }}" | ||
with_items: "{{ groups['cluster_hosts'] }}" | ||
|
||
- name: "Set the private DNS server to use the external value (if provided)" | ||
set_fact: | ||
nsupdate_server_private: "{{ external_nsupdate_keys['private']['server'] }}" | ||
nsupdate_key_secret_private: "{{ external_nsupdate_keys['private']['key_secret'] }}" | ||
nsupdate_key_algorithm_private: "{{ external_nsupdate_keys['private']['key_algorithm'] }}" | ||
when: | ||
- external_nsupdate_keys is defined | ||
- external_nsupdate_keys['private'] is defined | ||
|
||
- name: "Set the private DNS server to use the provisioned value" | ||
set_fact: | ||
nsupdate_server_private: "{{ hostvars[groups['dns'][0]].openstack.public_v4 }}" | ||
nsupdate_key_secret_private: "{{ hostvars[groups['dns'][0]].nsupdate_keys['private-' + full_dns_domain].key_secret }}" | ||
nsupdate_key_algorithm_private: "{{ hostvars[groups['dns'][0]].nsupdate_keys['private-' + full_dns_domain].key_algorithm }}" | ||
when: | ||
- nsupdate_server_private is undefined | ||
|
||
- name: "Generate the private Add section for DNS" | ||
set_fact: | ||
private_named_records: | ||
- view: "private" | ||
zone: "{{ full_dns_domain }}" | ||
server: "{{ nsupdate_server_private }}" | ||
key_name: "{{ ( 'private-' + full_dns_domain ) }}" | ||
key_secret: "{{ nsupdate_key_secret_private }}" | ||
key_algorithm: "{{ nsupdate_key_algorithm_private | lower }}" | ||
entries: "{{ private_records }}" | ||
|
||
- name: "Generate list of public A records" | ||
set_fact: | ||
public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': hostvars[item]['ansible_hostname'], 'ip': hostvars[item]['openstack']['public_v4'] } ] }}" | ||
with_items: "{{ groups['cluster_hosts'] }}" | ||
|
||
- name: "Add wildcard records to the public A records" | ||
set_fact: | ||
public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': '*.' + openshift_app_domain, 'ip': hostvars[item]['openstack']['public_v4'] } ] }}" | ||
with_items: "{{ groups['infra_hosts'] }}" | ||
|
||
- name: "Set the public DNS server details to use the external value (if provided)" | ||
set_fact: | ||
nsupdate_server_public: "{{ external_nsupdate_keys['public']['server'] }}" | ||
nsupdate_key_secret_public: "{{ external_nsupdate_keys['public']['key_secret'] }}" | ||
nsupdate_key_algorithm_public: "{{ external_nsupdate_keys['public']['key_algorithm'] }}" | ||
when: | ||
- external_nsupdate_keys is defined | ||
- external_nsupdate_keys['public'] is defined | ||
|
||
- name: "Set the public DNS server details to use the provisioned value" | ||
set_fact: | ||
nsupdate_server_public: "{{ hostvars[groups['dns'][0]].openstack.public_v4 }}" | ||
nsupdate_key_secret_public: "{{ hostvars[groups['dns'][0]].nsupdate_keys['public-' + full_dns_domain].key_secret }}" | ||
nsupdate_key_algorithm_public: "{{ hostvars[groups['dns'][0]].nsupdate_keys['public-' + full_dns_domain].key_algorithm }}" | ||
when: | ||
- nsupdate_server_public is undefined | ||
|
||
- name: "Generate the public Add section for DNS" | ||
set_fact: | ||
public_named_records: | ||
- view: "public" | ||
zone: "{{ full_dns_domain }}" | ||
server: "{{ nsupdate_server_public }}" | ||
key_name: "{{ ( 'public-' + full_dns_domain ) }}" | ||
key_secret: "{{ nsupdate_key_secret_public }}" | ||
key_algorithm: "{{ nsupdate_key_algorithm_public | lower }}" | ||
entries: "{{ public_records }}" | ||
|
||
- name: "Generate the final dns_records_add" | ||
set_fact: | ||
dns_records_add: "{{ private_named_records + public_named_records }}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
|
||
- name: "Generate ACL list for DNS server" | ||
set_fact: | ||
acl_list: "{{ acl_list | default([]) + [ (hostvars[item]['openstack']['private_v4'] + '/32') ] }}" | ||
with_items: "{{ groups['cluster_hosts'] }}" | ||
|
||
- name: "Generate the private view" | ||
set_fact: | ||
private_named_view: | ||
- name: "private" | ||
acl_entry: "{{ acl_list }}" | ||
zone: | ||
- dns_domain: "{{ full_dns_domain }}" | ||
|
||
- name: "Generate the public view" | ||
set_fact: | ||
public_named_view: | ||
- name: "public" | ||
zone: | ||
- dns_domain: "{{ full_dns_domain }}" | ||
forwarder: "{{ public_dns_nameservers }}" | ||
|
||
- name: "Generate the final named_config_views" | ||
set_fact: | ||
named_config_views: "{{ private_named_view + public_named_view }}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
|
||
# Assign hostnames | ||
- hosts: cluster_hosts | ||
pre_tasks: | ||
- include: roles/common/pre_tasks/pre_tasks.yml | ||
roles: | ||
- role: hostnames | ||
|
||
# Subscribe DNS Host to allow for configuration below | ||
- hosts: dns | ||
roles: | ||
- { role: subscription-manager, when: hostvars.localhost.rhsm_register, tags: 'subscription-manager', ansible_sudo: true } | ||
|
||
# Determine which DNS server(s) to use for our generated records | ||
- hosts: localhost | ||
roles: | ||
- dns-server-detect | ||
|
||
# Build the DNS Server Views and Configure DNS Server(s) | ||
- hosts: dns | ||
pre_tasks: | ||
- include: roles/common/pre_tasks/pre_tasks.yml | ||
- name: "Generate dns-server views" | ||
include: openstack_dns_views.yml | ||
roles: | ||
- role: dns-server | ||
|
||
# Build and process DNS Records | ||
- hosts: localhost | ||
pre_tasks: | ||
- include: roles/common/pre_tasks/pre_tasks.yml | ||
- name: "Generate dns records" | ||
include: openstack_dns_records.yml | ||
roles: | ||
- role: dns | ||
|
||
# Use newly configured DNS server for this container ... | ||
- hosts: localhost | ||
tasks: | ||
- name: "Edit /etc/resolv.conf in container" | ||
shell: "sed '0,/.*nameserver.*/s/.*nameserver.*/nameserver {{ public_dns_server }} \\n&/' /etc/resolv.conf > /tmp/resolv.conf && /bin/cp -f /tmp/resolv.conf /etc/resolv.conf" | ||
|
||
# OpenShift Pre-Requisites | ||
- hosts: OSEv3 | ||
tasks: | ||
- name: "Edit /etc/resolv.conf on masters/nodes" | ||
lineinfile: | ||
state: present | ||
dest: /etc/resolv.conf | ||
regexp: "nameserver {{ hostvars['localhost'].private_dns_server }}" | ||
line: "nameserver {{ hostvars['localhost'].private_dns_server }}" | ||
insertafter: search* | ||
- name: "Include DNS configuration to ensure proper name resolution" | ||
lineinfile: | ||
state: present | ||
dest: /etc/sysconfig/network | ||
regexp: "IP4_NAMESERVERS={{ hostvars['localhost'].private_dns_server }}" | ||
line: "IP4_NAMESERVERS={{ hostvars['localhost'].private_dns_server }}" | ||
|
Oops, something went wrong.