diff --git a/playbooks/provisioning/openstack/advanced-configuration.md b/playbooks/provisioning/openstack/advanced-configuration.md index 5a57d3371..c7ed0463f 100644 --- a/playbooks/provisioning/openstack/advanced-configuration.md +++ b/playbooks/provisioning/openstack/advanced-configuration.md @@ -182,15 +182,25 @@ So the provisioned cluster nodes will start using those natively as default nameservers. Technically, this allows to deploy OpenShift clusters without dnsmasq proxies. -The `env_id` and `public_dns_domain` will form the cluster's DNS domain all -your servers will be under. With the default values, this will be -`openshift.example.com`. For workloads, the default subdomain is 'apps'. -That sudomain can be set as well by the `openshift_app_domain` variable in -the inventory. +The `openshift_openstack_clusterid` and `openshift_openstack_public_dns_domain` +will form the cluster's DNS domain all your servers will be under. With the +default values, this will be `openshift.example.com`. For workloads, the default +subdomain is 'apps'. That sudomain can be set as well by the +`openshift_app_domain` variable in the inventory. + +If you want to use different public and private DNS records for your servers, +specify `openshift_openstack_public_hostname_suffix` and/or +`openshift_openstack_private_hostname_suffix`. These suffixes default to the +`openshift_openstack_clusterid` subdomain. Or you may want to specify another +private domain with `openshift_openstack_private_dns_domain`. Note that +the servers' hostnames will not be updated. The deployment may be done on the +arbitrary named hosts. The `openstack__hostname` is a set of variables used for customising -hostnames of servers with a given role. When such a variable stays commented, -default hostname (usually the role name) is used. +names of servers (not hostnames) with a given role. When such a variable stays +commented, default name (usually the role name) is used for a Nova server name +and associated with it Heat resources and ansible inventory variables, like +`openshift_(public)_hostname`. The `public_dns_nameservers` is a list of DNS servers accessible from all the created Nova servers. These will be serving as your DNS forwarders for diff --git a/playbooks/provisioning/openstack/post-provision-openstack.yml b/playbooks/provisioning/openstack/post-provision-openstack.yml index e460fbf12..4f45da54c 100644 --- a/playbooks/provisioning/openstack/post-provision-openstack.yml +++ b/playbooks/provisioning/openstack/post-provision-openstack.yml @@ -21,13 +21,6 @@ - name: OpenShift Pre-Requisites (part 1) include: pre-install.yml -- name: Assign hostnames - hosts: cluster_hosts - gather_facts: False - become: true - roles: - - role: hostnames - - name: Subscribe DNS Host to allow for configuration below hosts: dns gather_facts: False diff --git a/playbooks/provisioning/openstack/pre_tasks.yml b/playbooks/provisioning/openstack/pre_tasks.yml index 11fe2dd84..dd241f7de 100644 --- a/playbooks/provisioning/openstack/pre_tasks.yml +++ b/playbooks/provisioning/openstack/pre_tasks.yml @@ -12,12 +12,20 @@ - name: Setting Common Facts set_fact: - env_id: "{{ env_id | default(default_env_id) }}" + openshift_openstack_clusterid: "{{ openshift_openstack_clusterid | default(default_env_id) }}" + openshift_openstack_public_dns_domain: "{{ public_dns_domain }}" delegate_to: localhost -- name: Updating DNS domain to include env_id (if not empty) +- name: Setting DNS hostnames suffixes set_fact: - full_dns_domain: "{{ (env_id|trim == '') | ternary(public_dns_domain, env_id + '.' + public_dns_domain) }}" + openshift_openstack_public_hostname_suffix: "{{ openshift_openstack_public_hostname_suffix|default(openshift_openstack_clusterid) }}" + openshift_openstack_private_hostname_suffix: "{{ openshift_openstack_private_hostname_suffix|default(openshift_openstack_clusterid) }}" + delegate_to: localhost + +- name: Updating DNS domain to include cluster id (if not empty) + set_fact: + openshift_openstack_full_public_dns_domain: "{{ (openshift_openstack_public_hostname_suffix|trim == '') | ternary(openshift_openstack_public_dns_domain, openshift_openstack_public_hostname_suffix + '.' + openshift_openstack_public_dns_domain) }}" + openshift_openstack_full_private_dns_domain: "{{ (openshift_openstack_private_hostname_suffix|trim == '') | ternary(openshift_openstack_private_dns_domain, openshift_openstack_private_hostname_suffix + '.' + openshift_openstack_private_dns_domain) }}" delegate_to: localhost - name: Set the APP domain for OpenShift use @@ -27,7 +35,7 @@ - name: Set the default app domain for routing purposes set_fact: - openshift_master_default_subdomain: "{{ openshift_app_domain }}.{{ full_dns_domain }}" + openshift_master_default_subdomain: "{{ openshift_app_domain }}.{{ openshift_openstack_full_public_dns_domain }}" delegate_to: localhost when: - openshift_master_default_subdomain is undefined diff --git a/playbooks/provisioning/openstack/sample-inventory/group_vars/OSEv3.yml b/playbooks/provisioning/openstack/sample-inventory/group_vars/OSEv3.yml index 4c1ca8c96..a34cf9c44 100644 --- a/playbooks/provisioning/openstack/sample-inventory/group_vars/OSEv3.yml +++ b/playbooks/provisioning/openstack/sample-inventory/group_vars/OSEv3.yml @@ -2,11 +2,11 @@ openshift_deployment_type: origin #openshift_deployment_type: openshift-enterprise #openshift_release: v3.5 -openshift_master_default_subdomain: "apps.{{ env_id }}.{{ public_dns_domain }}" +openshift_master_default_subdomain: "apps.{{ openshift_openstack_full_public_dns_domain }}" openshift_master_cluster_method: native -openshift_master_cluster_public_hostname: "console.{{ env_id }}.{{ public_dns_domain }}" -openshift_master_cluster_hostname: "{{ openshift_master_cluster_public_hostname }}" +openshift_master_cluster_public_hostname: "console.{{ openshift_openstack_full_public_dns_domain }}" +openshift_master_cluster_hostname: "console.{{ openshift_openstack_full_private_dns_domain }}" osm_default_node_selector: 'region=primary' diff --git a/playbooks/provisioning/openstack/sample-inventory/group_vars/all.yml b/playbooks/provisioning/openstack/sample-inventory/group_vars/all.yml index ad0511cb2..c0d4ffc9d 100644 --- a/playbooks/provisioning/openstack/sample-inventory/group_vars/all.yml +++ b/playbooks/provisioning/openstack/sample-inventory/group_vars/all.yml @@ -3,6 +3,20 @@ env_id: "openshift" public_dns_domain: "example.com" public_dns_nameservers: [] +# FIXME(bogdando) transitioning variable names for compatibility with +# https://github.com/openshift/openshift-ansible/pull/6039 namespaces +# remove it once resubmitted by the new location in openshift-ansible +openshift_openstack_clusterid: "{{ env_id }}" +openshift_openstack_public_dns_domain: "{{ public_dns_domain }}" + +# Allows to override the suffix provided in openshift_openstack_clusterid +# and the private DNS domain. +openshift_openstack_public_hostname_suffix: "{{ openshift_openstack_clusterid }}" +openshift_openstack_private_hostname_suffix: "{{ openshift_openstack_clusterid }}" +openshift_openstack_private_dns_domain: "{{ openshift_openstack_public_dns_domain }}" +openshift_openstack_full_public_dns_domain: "{{ (openshift_openstack_public_hostname_suffix|trim == '') | ternary(openshift_openstack_public_dns_domain, openshift_openstack_public_hostname_suffix + '.' + openshift_openstack_public_dns_domain) }}" +openshift_openstack_full_private_dns_domain: "{{ (openshift_openstack_private_hostname_suffix|trim == '') | ternary(openshift_openstack_private_dns_domain, openshift_openstack_private_hostname_suffix + '.' + openshift_openstack_private_dns_domain) }}" + # Used Hostnames # - set custom hostnames for roles by uncommenting corresponding lines #openstack_master_hostname: "master" @@ -149,7 +163,7 @@ ansible_user: openshift # The Nova keypair's private SSH key to access inventory nodes. #openstack_private_ssh_key: ~/.ssh/id_rsa # The path for the SSH config to access all nodes -#openstack_ssh_config_path: /tmp/ssh.config.openshift.ansible.{{ env_id }}.{{ public_dns_domain }} +#openstack_ssh_config_path: /tmp/ssh.config.openshift.ansible.{{ openshift_openstack_full_public_dns_domain }} # If you want to use the VM storage instead of Cinder volumes, set this to `true`. # NOTE: this is for testing only! Your data will be gone once the VM disappears! diff --git a/playbooks/provisioning/openstack/sample-inventory/inventory.py b/playbooks/provisioning/openstack/sample-inventory/inventory.py index 6a1b74b3d..7ccde19f5 100755 --- a/playbooks/provisioning/openstack/sample-inventory/inventory.py +++ b/playbooks/provisioning/openstack/sample-inventory/inventory.py @@ -72,12 +72,18 @@ 'ansible_host': ssh_ip_address } + vars['openshift_public_hostname'] = server.name + if 'private_fqdn' in server.metadata: + vars['openshift_hostname'] = server.metadata.private_fqdn + public_v4 = server.public_v4 or server.private_v4 if public_v4: - vars['public_v4'] = public_v4 + vars['public_v4'] = server.public_v4 + vars['openshift_public_ip'] = server.public_v4 # TODO(shadower): what about multiple networks? if server.private_v4: vars['private_v4'] = server.private_v4 + vars['openshift_ip'] = server.private_v4 node_labels = server.metadata.get('node_labels') if node_labels: diff --git a/roles/dns-records/tasks/main.yml b/roles/dns-records/tasks/main.yml index 7148b016a..c2a4b428b 100644 --- a/roles/dns-records/tasks/main.yml +++ b/roles/dns-records/tasks/main.yml @@ -11,14 +11,14 @@ - name: "Add public master cluster hostname records to the private A records (single master)" set_fact: - private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.masters[0]].private_v4 } ] }}" + private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(openshift_openstack_full_public_dns_domain, ''))[:-1], 'ip': hostvars[groups.masters[0]].private_v4 } ] }}" when: - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined - openstack_num_masters == 1 - name: "Add public master cluster hostname records to the private A records (multi-master)" set_fact: - private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.lb[0]].private_v4 } ] }}" + private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(openshift_openstack_full_public_dns_domain, ''))[:-1], 'ip': hostvars[groups.lb[0]].private_v4 } ] }}" when: - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined - openstack_num_masters > 1 @@ -28,7 +28,7 @@ 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'] }}" - nsupdate_private_key_name: "{{ external_nsupdate_keys['private']['key_name']|default('private-' + full_dns_domain) }}" + nsupdate_private_key_name: "{{ external_nsupdate_keys['private']['key_name']|default('private-' + openshift_openstack_full_private_dns_domain) }}" when: - external_nsupdate_keys is defined - external_nsupdate_keys['private'] is defined @@ -36,22 +36,41 @@ - name: "Set the private DNS server to use the provisioned value" set_fact: nsupdate_server_private: "{{ hostvars[groups['dns'][0]].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 }}" + nsupdate_key_secret_private: "{{ hostvars[groups['dns'][0]].nsupdate_keys['private-' + openshift_openstack_full_private_dns_domain].key_secret }}" + nsupdate_key_algorithm_private: "{{ hostvars[groups['dns'][0]].nsupdate_keys['private-' + openshift_openstack_full_private_dns_domain].key_algorithm }}" when: - nsupdate_server_private is undefined +- name: "Set the private DNS server to use the provisioned value for multiple hostnames" + set_fact: + nsupdate_key_secret_private_public: "{{ hostvars[groups['dns'][0]].nsupdate_keys['private-' + openshift_openstack_full_public_dns_domain].key_secret }}" + when: + - openshift_openstack_full_public_dns_domain != openshift_openstack_full_private_dns_domain + - name: "Generate the private Add section for DNS" set_fact: private_named_records: - view: "private" - zone: "{{ full_dns_domain }}" + zone: "{{ openshift_openstack_full_private_dns_domain }}" server: "{{ nsupdate_server_private }}" - key_name: "{{ nsupdate_private_key_name|default('private-' + full_dns_domain) }}" + key_name: "{{ nsupdate_private_key_name|default('private-' + openshift_openstack_full_private_dns_domain) }}" key_secret: "{{ nsupdate_key_secret_private }}" key_algorithm: "{{ nsupdate_key_algorithm_private | lower }}" entries: "{{ private_records }}" +- name: "Generate the private for public Add section for DNS" + set_fact: + private_named_records: + - view: "private" + zone: "{{ openshift_openstack_full_public_dns_domain }}" + server: "{{ nsupdate_server_private }}" + key_name: "{{ 'private-' + openshift_openstack_full_public_dns_domain }}" + key_secret: "{{ nsupdate_key_secret_private_public }}" + key_algorithm: "{{ nsupdate_key_algorithm_private | lower }}" + entries: "{{ private_records }}" + when: + - openshift_openstack_full_public_dns_domain != openshift_openstack_full_private_dns_domain + - name: "Generate list of public A records" set_fact: public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': hostvars[item]['ansible_hostname'], 'ip': hostvars[item]['public_v4'] } ] }}" @@ -66,7 +85,7 @@ - name: "Add public master cluster hostname records to the public A records (single master)" set_fact: - public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.masters[0]].public_v4 } ] }}" + public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(openshift_openstack_full_public_dns_domain, ''))[:-1], 'ip': hostvars[groups.masters[0]].public_v4 } ] }}" when: - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined - openstack_num_masters == 1 @@ -74,7 +93,7 @@ - name: "Add public master cluster hostname records to the public A records (single master behind a bastion)" set_fact: - public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.bastions[0]].public_v4 } ] }}" + public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(openshift_openstack_full_public_dns_domain, ''))[:-1], 'ip': hostvars[groups.bastions[0]].public_v4 } ] }}" when: - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined - openstack_num_masters == 1 @@ -82,7 +101,7 @@ - name: "Add public master cluster hostname records to the public A records (multi-master)" set_fact: - public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(full_dns_domain, ''))[:-1], 'ip': hostvars[groups.lb[0]].public_v4 } ] }}" + public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'hostname': (hostvars[groups.masters[0]].openshift_master_cluster_public_hostname | replace(openshift_openstack_full_public_dns_domain, ''))[:-1], 'ip': hostvars[groups.lb[0]].public_v4 } ] }}" when: - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined - openstack_num_masters > 1 @@ -92,7 +111,7 @@ 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'] }}" - nsupdate_public_key_name: "{{ external_nsupdate_keys['public']['key_name']|default('public-' + full_dns_domain) }}" + nsupdate_public_key_name: "{{ external_nsupdate_keys['public']['key_name']|default('public-' + openshift_openstack_full_public_dns_domain) }}" when: - external_nsupdate_keys is defined - external_nsupdate_keys['public'] is defined @@ -100,8 +119,8 @@ - name: "Set the public DNS server details to use the provisioned value" set_fact: nsupdate_server_public: "{{ hostvars[groups['dns'][0]].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 }}" + nsupdate_key_secret_public: "{{ hostvars[groups['dns'][0]].nsupdate_keys['public-' + openshift_openstack_full_public_dns_domain].key_secret }}" + nsupdate_key_algorithm_public: "{{ hostvars[groups['dns'][0]].nsupdate_keys['public-' + openshift_openstack_full_public_dns_domain].key_algorithm }}" when: - nsupdate_server_public is undefined @@ -109,9 +128,9 @@ set_fact: public_named_records: - view: "public" - zone: "{{ full_dns_domain }}" + zone: "{{ openshift_openstack_full_public_dns_domain }}" server: "{{ nsupdate_server_public }}" - key_name: "{{ nsupdate_public_key_name|default('public-' + full_dns_domain) }}" + key_name: "{{ nsupdate_public_key_name|default('public-' + openshift_openstack_full_public_dns_domain) }}" key_secret: "{{ nsupdate_key_secret_public }}" key_algorithm: "{{ nsupdate_key_algorithm_public | lower }}" entries: "{{ public_records }}" diff --git a/roles/dns-views/tasks/main.yml b/roles/dns-views/tasks/main.yml index ffbad2e3f..524a8d9b0 100644 --- a/roles/dns-views/tasks/main.yml +++ b/roles/dns-views/tasks/main.yml @@ -4,6 +4,20 @@ acl_list: "{{ acl_list | default([]) + [ (hostvars[item]['private_v4'] + '/32') ] }}" with_items: "{{ groups['cluster_hosts'] }}" +- name: "Generate the private view for multiple hostnames" + set_fact: + private_named_view: + - name: "private" + recursion: "{{ named_private_recursion }}" + acl_entry: "{{ acl_list }}" + zone: + - dns_domain: "{{ openshift_openstack_full_private_dns_domain }}" + - dns_domain: "{{ openshift_openstack_full_public_dns_domain }}" + forwarder: "{{ public_dns_nameservers }}" + when: + - external_nsupdate_keys['private'] is undefined + - openshift_openstack_full_private_dns_domain != openshift_openstack_full_public_dns_domain + - name: "Generate the private view" set_fact: private_named_view: @@ -11,9 +25,11 @@ recursion: "{{ named_private_recursion }}" acl_entry: "{{ acl_list }}" zone: - - dns_domain: "{{ full_dns_domain }}" + - dns_domain: "{{ openshift_openstack_full_private_dns_domain }}" forwarder: "{{ public_dns_nameservers }}" - when: external_nsupdate_keys['private'] is undefined + when: + - external_nsupdate_keys['private'] is undefined + - openshift_openstack_full_private_dns_domain == openshift_openstack_full_public_dns_domain - name: "Generate the public view" set_fact: @@ -21,7 +37,7 @@ - name: "public" recursion: "{{ named_public_recursion }}" zone: - - dns_domain: "{{ full_dns_domain }}" + - dns_domain: "{{ openshift_openstack_full_public_dns_domain }}" forwarder: "{{ public_dns_nameservers }}" when: external_nsupdate_keys['public'] is undefined diff --git a/roles/hostnames/tasks/main.yaml b/roles/hostnames/tasks/main.yaml deleted file mode 100644 index e8bdd5ade..000000000 --- a/roles/hostnames/tasks/main.yaml +++ /dev/null @@ -1,43 +0,0 @@ ---- -- name: Setting Hostname Fact - set_fact: - new_hostname: "{{ custom_hostname | default(inventory_hostname_short) }}" - -- name: Setting FQDN Fact - set_fact: - new_fqdn: "{{ new_hostname }}.{{ full_dns_domain }}" - -# Ansible 2.5 fixed the hostname module for RHEL 7.5: https://github.com/ansible/ansible/pull/31839 -- name: Checking if this version of Ansible has a fix for the hostname module - set_fact: - hostname_module_fixed: "{{ ansible_version['full'] | version_compare('2.5', '>=') }}" - -# The hostname module does not work on RHEL version 7.5 with Ansible versions < 2.5 -- name: Checking if this version of RHEL is affected by the hostname problem - set_fact: - rhel75: "{{ (ansible_distribution == 'RedHat') and (ansible_distribution_version | version_compare('7.5', '>=')) }}" - -- name: Setting hostname and DNS domain - hostname: name="{{ new_fqdn }}" - # Use the hostname module when not on RHEL 7.5 or on the version of Ansible that fixed the hostname module. - when: not rhel75 or hostname_module_fixed - -- name: Setting hostname and DNS domain using the command module - command: "hostname {{ new_fqdn }}" - # Use the command module when RHEL 7.5 or later, and when Ansible does not contain the hostname module fix. - when: rhel75 and not hostname_module_fixed - -- name: Check for cloud.cfg - stat: path=/etc/cloud/cloud.cfg - register: cloud_cfg - -- name: Prevent cloud-init updates of hostname/fqdn (if applicable) - lineinfile: - dest: /etc/cloud/cloud.cfg - state: present - regexp: "{{ item.regexp }}" - line: "{{ item.line }}" - with_items: - - { regexp: '^ - set_hostname', line: '# - set_hostname' } - - { regexp: '^ - update_hostname', line: '# - update_hostname' } - when: cloud_cfg.stat.exists == True diff --git a/roles/hostnames/test/inv b/roles/hostnames/test/inv deleted file mode 100644 index ffbe6e03d..000000000 --- a/roles/hostnames/test/inv +++ /dev/null @@ -1,12 +0,0 @@ -[all:vars] -dns_domain=example.com - -[openshift_masters] -192.168.124.41 dns_private_ip=1.1.1.41 dns_public_ip=192.168.124.41 -192.168.124.117 dns_private_ip=1.1.1.117 dns_public_ip=192.168.124.117 - -[openshift_nodes] -192.168.124.40 dns_private_ip=1.1.1.40 dns_public_ip=192.168.124.40 - -#[dns] -#192.168.124.117 dns_private_ip=1.1.1.117 diff --git a/roles/hostnames/test/roles b/roles/hostnames/test/roles deleted file mode 120000 index e2b799b9d..000000000 --- a/roles/hostnames/test/roles +++ /dev/null @@ -1 +0,0 @@ -../../../roles/ \ No newline at end of file diff --git a/roles/hostnames/test/test.retry b/roles/hostnames/test/test.retry deleted file mode 100644 index 63fc08e4c..000000000 --- a/roles/hostnames/test/test.retry +++ /dev/null @@ -1,3 +0,0 @@ -192.168.124.117 -192.168.124.40 -192.168.124.41 diff --git a/roles/hostnames/test/test.yaml b/roles/hostnames/test/test.yaml deleted file mode 100644 index 0c56aea51..000000000 --- a/roles/hostnames/test/test.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -- hosts: all - roles: - - role: hostnames diff --git a/roles/hostnames/vars/main.yaml b/roles/hostnames/vars/main.yaml deleted file mode 100644 index 3eecb8dc4..000000000 --- a/roles/hostnames/vars/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -counter: 1 diff --git a/roles/hostnames/vars/records.yaml b/roles/hostnames/vars/records.yaml deleted file mode 100644 index 0cadc8181..000000000 --- a/roles/hostnames/vars/records.yaml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- name: "Building Records" - set_fact: - dns_records_add: - - view: private - zone: example.com - entries: - - type: A - hostname: master1.example.com - ip: 172.16.15.94 - - type: A - hostname: node1.example.com - ip: 172.16.15.86 - - type: A - hostname: node2.example.com - ip: 172.16.15.87 - - view: public - zone: example.com - entries: - - type: A - hostname: master1.example.com - ip: 10.3.10.116 - - type: A - hostname: node1.example.com - ip: 10.3.11.46 - - type: A - hostname: node2.example.com - ip: 10.3.12.6 diff --git a/roles/openstack-stack/templates/heat_stack.yaml.j2 b/roles/openstack-stack/templates/heat_stack.yaml.j2 index 2359842a5..7bc42b55a 100644 --- a/roles/openstack-stack/templates/heat_stack.yaml.j2 +++ b/roles/openstack-stack/templates/heat_stack.yaml.j2 @@ -521,6 +521,9 @@ resources: params: cluster_id: {{ stack_name }} k8s_type: {{ etcd_hostname | default('etcd') }} +{% if openshift_openstack_private_dns_domain != openshift_openstack_public_dns_domain %} + private_fqdn: {{ etcd_hostname | default('etcd') }}-%index%.{{ openshift_openstack_private_dns_domain }} +{% endif %} cluster_env: {{ public_dns_domain }} cluster_id: {{ stack_name }} group: @@ -590,6 +593,9 @@ resources: params: cluster_id: {{ stack_name }} k8s_type: {{ lb_hostname | default('lb') }} +{% if openshift_openstack_private_dns_domain != openshift_openstack_public_dns_domain %} + private_fqdn: {{ lb_hostname | default('lb') }}-%index%.{{ openshift_openstack_private_dns_domain }} +{% endif %} cluster_env: {{ public_dns_domain }} cluster_id: {{ stack_name }} group: @@ -640,6 +646,9 @@ resources: params: cluster_id: {{ stack_name }} k8s_type: {{ master_hostname | default('master')}} +{% if openshift_openstack_private_dns_domain != openshift_openstack_public_dns_domain %} + private_fqdn: {{ master_hostname | default('master') }}-%index%.{{ openshift_openstack_private_dns_domain }} +{% endif %} cluster_env: {{ public_dns_domain }} cluster_id: {{ stack_name }} group: @@ -713,6 +722,9 @@ resources: params: cluster_id: {{ stack_name }} sub_type_k8s_type: {{ node_hostname | default('app-node') }} +{% if openshift_openstack_private_dns_domain != openshift_openstack_public_dns_domain %} + private_fqdn: {{ node_hostname | default('app-node') }}-%index%.{{ openshift_openstack_private_dns_domain }} +{% endif %} cluster_env: {{ public_dns_domain }} cluster_id: {{ stack_name }} group: @@ -777,6 +789,9 @@ resources: params: cluster_id: {{ stack_name }} sub_type_k8s_type: {{ infra_hostname | default('infranode') }} +{% if openshift_openstack_private_dns_domain != openshift_openstack_public_dns_domain %} + private_fqdn: {{ infra_hostname | default('infranode') }}-%index%.{{ openshift_openstack_private_dns_domain }} +{% endif %} cluster_env: {{ public_dns_domain }} cluster_id: {{ stack_name }} group: @@ -850,6 +865,9 @@ resources: params: cluster_id: {{ stack_name }} k8s_type: {{ dns_hostname | default('dns') }} +{% if openshift_openstack_private_dns_domain != openshift_openstack_public_dns_domain %} + private_fqdn: {{ dns_hostname | default('dns') }}-%index%.{{ openshift_openstack_private_dns_domain }} +{% endif %} cluster_env: {{ public_dns_domain }} cluster_id: {{ stack_name }} group: diff --git a/roles/openstack-stack/templates/heat_stack_server.yaml.j2 b/roles/openstack-stack/templates/heat_stack_server.yaml.j2 index 9ffe721a5..a78ed1807 100644 --- a/roles/openstack-stack/templates/heat_stack_server.yaml.j2 +++ b/roles/openstack-stack/templates/heat_stack_server.yaml.j2 @@ -7,7 +7,14 @@ parameters: name: type: string label: Name - description: Name + description: Public (FQDN) Name + +{% if openshift_openstack_private_dns_domain != openshift_openstack_public_dns_domain %} + private_fqdn: + type: string + label: Name + description: Private (FQDN) Name +{% endif %} group: type: string @@ -212,6 +219,9 @@ resources: host-type: { get_param: type } sub-host-type: { get_param: subtype } node_labels: { get_param: node_labels } +{% if openshift_openstack_private_dns_domain != openshift_openstack_public_dns_domain %} + private_fqdn: { get_param: private_fqdn } +{% endif %} scheduler_hints: { get_param: scheduler_hints } {% if use_trunk_ports|default(false)|bool %} diff --git a/roles/static_inventory/tasks/openstack.yml b/roles/static_inventory/tasks/openstack.yml index adf78c966..992af2599 100644 --- a/roles/static_inventory/tasks/openstack.yml +++ b/roles/static_inventory/tasks/openstack.yml @@ -51,6 +51,11 @@ private_v4: >- {% set node = registered_nodes | json_query("[?name=='" + item.name + "']") -%} {{ node[0].addresses[openstack_private_network|quote][0].addr }} + openshift_ip: >- + {% set node = registered_nodes | json_query("[?name=='" + item.name + "']") -%} + {{ node[0].addresses[openstack_private_network|quote][0].addr }} + openshift_hostname: '{{ item.metadata.private_fqdn|default(omit) }}' + openshift_public_hostname: '{{ item.name }}' - name: Add cluster nodes with floating IPs to inventory with_items: "{{ registered_nodes_floating }}" @@ -77,6 +82,17 @@ {%- else -%} {{ item.public_v4 }} {%- endif %} + openshift_ip: >- + {% set node = registered_nodes | json_query("[?name=='" + item.name + "']") -%} + {{ node[0].addresses[openstack_private_network|quote][0].addr }} + openshift_public_ip: >- + {% if openstack_provider_network_name|default(None) -%} + {{ item.private_v4 }} + {%- else -%} + {{ item.public_v4 }} + {%- endif %} + openshift_hostname: '{{ item.metadata.private_fqdn|default(omit) }}' + openshift_public_hostname: '{{ item.name }}' # Split registered_nodes into old nodes and new app nodes # Add new app nodes to new_nodes host group for upscaling diff --git a/roles/static_inventory/templates/inventory.j2 b/roles/static_inventory/templates/inventory.j2 index 9dfbe3a5b..2dc1449d4 100644 --- a/roles/static_inventory/templates/inventory.j2 +++ b/roles/static_inventory/templates/inventory.j2 @@ -6,10 +6,18 @@ {{ host }}{% if 'ansible_host' in hostvars[host] %} ansible_host={{ hostvars[host]['ansible_host'] }}{% endif %} +{% if 'openshift_hostname' in hostvars[host] +%} openshift_hostname={{ hostvars[host]['openshift_hostname'] }}{% endif %} +{% if 'openshift_public_hostname' in hostvars[host] +%} openshift_public_hostname={{ hostvars[host]['openshift_public_hostname'] }}{% endif %} {% if 'private_v4' in hostvars[host] %} private_v4={{ hostvars[host]['private_v4'] }}{% endif %} {% if 'public_v4' in hostvars[host] %} public_v4={{ hostvars[host]['public_v4'] }}{% endif %} +{% if 'openshift_ip' in hostvars[host] +%} openshift_ip={{ hostvars[host]['openshift_ip'] }}{% endif %} +{% if 'openshift_public_ip' in hostvars[host] +%} openshift_public_ip={{ hostvars[host]['openshift_public_ip'] }}{% endif %} {% if 'ansible_user' in hostvars[host] %} ansible_user={{ hostvars[host]['ansible_user'] }}{% endif %} {% if 'ansible_private_key_file' in hostvars[host] and hostvars[host]['ansible_private_key_file']