Browse Source

Fix nsupdate with allinone

Running the allinone deployment was failing our nsupdate tasks.

So this code makes them more robust and only tries to create records
when the required values are present.
Tomas Sedovic 6 years ago
parent
commit
5d0b3c8a45

+ 2 - 5
playbooks/openstack/configuration.md

@@ -305,11 +305,8 @@ The options here define a new OpenShift node group that has the labels for all
 three roles: master, infra and compute. And we create a single node and assign
 this new group to it.
 
-It doesn't matter which node role you choose. You can do the equivalent by
-setting `openshift_openstack_num_infra: 1` and
-`openshift_openstack_infra_group_name: node-config-all-in-one` or
-`openshift_openstack_num_nodes: 1` and `openshift_openstack_compute_group_name:
-node-config-all-in-one`.
+Note that the "all in one" node must be the "master". openshift-ansible
+expects at least one node in the `masters` Ansible group.
 
 
 

+ 28 - 3
roles/openshift_openstack/tasks/generate-dns.yml

@@ -3,19 +3,32 @@
   set_fact:
     private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'fqdn': hostvars[item]['ansible_hostname'] + openshift_openstack_private_hostname_suffix + '.' + openshift_openstack_full_dns_domain, 'ip': hostvars[item]['private_v4'] } ] }}"
   with_items: "{{ groups['cluster_hosts'] }}"
+  when:
+  - hostvars[item]['private_v4'] is defined
+  - hostvars[item]['private_v4'] is not none
+  - hostvars[item]['private_v4'] | string
 
 - name: "Add wildcard records to the private A records for infrahosts"
   set_fact:
     private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'fqdn': '*.' + hostvars[groups.masters[0]].openshift_master_default_subdomain, 'ip': hostvars[item]['private_v4'] } ] }}"
   with_items: "{{ groups['infra_hosts'] }}"
-  when: openshift_openstack_public_router_ip is defined
+  when:
+  - groups.masters
+  - hostvars[groups.masters[0]].openshift_master_default_subdomain is defined
+  - openshift_openstack_public_router_ip is defined
+  - openshift_openstack_public_router_ip is not none
+  - openshift_openstack_public_router_ip | string
 
+- debug: var=openshift_openstack_private_api_ip
 - name: "Add public master cluster hostname records to the private A records"
   set_fact:
     private_records: "{{ private_records | default([]) + [ { 'type': 'A', 'fqdn': hostvars[groups.masters[0]].openshift_master_cluster_public_hostname, 'ip': openshift_openstack_private_api_ip } ] }}"
   when:
+    - groups.masters
     - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
     - openshift_openstack_private_api_ip is defined
+    - openshift_openstack_private_api_ip is not none
+    - openshift_openstack_private_api_ip | string
 
 - name: "Set the private DNS server to use the external value (if provided)"
   set_fact:
@@ -39,24 +52,35 @@
         entries: "{{ private_records }}"
   when:
     - openshift_openstack_external_nsupdate_keys['private'] is defined
+    - private_records is defined
 
 - name: "Generate list of public A records"
   set_fact:
     public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'fqdn': hostvars[item]['ansible_hostname'] + openshift_openstack_public_hostname_suffix + '.' + openshift_openstack_full_dns_domain, 'ip': hostvars[item]['public_v4'] } ] }}"
   with_items: "{{ groups['cluster_hosts'] }}"
-  when: hostvars[item]['public_v4'] is defined
+  when:
+  - hostvars[item]['public_v4'] is defined
+  - hostvars[item]['public_v4'] | string
 
 - name: "Add wildcard record to the public A records"
   set_fact:
     public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'fqdn': '*.' + hostvars[groups.masters[0]].openshift_master_default_subdomain, 'ip': openshift_openstack_public_router_ip } ] }}"
-  when: openshift_openstack_public_router_ip is defined
+  when:
+  - groups.masters
+  - hostvars[groups.masters[0]].openshift_master_default_subdomain is defined
+  - openshift_openstack_public_router_ip is defined
+  - openshift_openstack_public_router_ip is not none
+  - openshift_openstack_public_router_ip | string
 
 - name: "Add the public API entry point record"
   set_fact:
     public_records: "{{ public_records | default([]) + [ { 'type': 'A', 'fqdn': hostvars[groups.masters[0]].openshift_master_cluster_public_hostname, 'ip': openshift_openstack_public_api_ip } ] }}"
   when:
+    - groups.masters
     - hostvars[groups.masters[0]].openshift_master_cluster_public_hostname is defined
     - openshift_openstack_public_api_ip is defined
+    - openshift_openstack_public_api_ip is not none
+    - openshift_openstack_public_api_ip | string
 
 - name: "Set the public DNS server details to use the external value (if provided)"
   set_fact:
@@ -79,6 +103,7 @@
         entries: "{{ public_records }}"
   when:
     - openshift_openstack_external_nsupdate_keys['public'] is defined
+    - public_records is defined
 
 
 - name: "Generate the final openshift_openstack_dns_records"