roles: bootstrap-host: Ensure DNS info from IDF is respected 13/58213/4
authorMarkos Chandras <mchandras@suse.de>
Mon, 4 Jun 2018 19:59:38 +0000 (20:59 +0100)
committerMarkos Chandras <mchandras@suse.de>
Wed, 6 Jun 2018 14:17:05 +0000 (15:17 +0100)
We are configuring static IPs in the various nodes but we don't do
anything for DNS assuming that DNS is being configured by another
entity. However, the IDF file already contains DNS information for us
so we should use that instead. Moreover, we update the IDF file to use
the gateway as DNS instead of the Google one in order to make it more
usable on restricted networks.

Change-Id: Ieba58ec9558080a1296e204c4f99bae859e9daef
Signed-off-by: Markos Chandras <mchandras@suse.de>
xci/playbooks/dynamic_inventory.py
xci/playbooks/roles/bootstrap-host/tasks/network_redhat.yml
xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml
xci/playbooks/roles/bootstrap-host/templates/osa/debian.interface.j2
xci/playbooks/roles/bootstrap-host/templates/osa/redhat.interface.j2
xci/var/idf.yml

index 6d9d217..b5c4609 100755 (executable)
@@ -47,6 +47,7 @@ class XCIInventory(object):
         self.opnfv_networks['opnfv']['public'] = {}
         self.opnfv_networks['opnfv']['public']['address'] = '192.168.122.2/24'
         self.opnfv_networks['opnfv']['public']['gateway'] = '192.168.122.1'
+        self.opnfv_networks['opnfv']['public']['dns'] = '192.168.122.1'
         self.opnfv_networks['opnfv']['private'] = {}
         self.opnfv_networks['opnfv']['private']['address'] = '172.29.240.10/22'
         self.opnfv_networks['opnfv']['storage'] = {}
@@ -110,6 +111,8 @@ class XCIInventory(object):
                 host_networks[hostname][network]['address'] = pdf_host_info['interfaces'][int(network_interface_num)]['address'] + "/" + str(ndata['mask'])
                 if 'gateway' in ndata.keys():
                     host_networks[hostname][network]['gateway'] = str(ndata['gateway']) + "/" + str(ndata['mask'])
+                if 'dns' in ndata.keys():
+                    host_networks[hostname][network]['dns'] = str(ndata['dns'])
 
             host_networks.update(self.opnfv_networks)
 
index b06a869..c360f15 100644 (file)
   loop_control:
     label: "{{ item.name }}"
 
-- name: Add default route through br-vlan
-  lineinfile:
-    path: "/etc/sysconfig/network-scripts/ifcfg-br-vlan"
-    line: "GATEWAY={{ host_info[inventory_hostname]['public']['gateway'] | ipaddr('address') }}"
-
 - name: restart network service
   service:
     name: network
index c9c9d83..e2b5aa4 100644 (file)
     dest: "/etc/sysconfig/network/scripts/network-config-suse"
     mode: 0755
 
+- name: Configure static DNS on SUSE
+  lineinfile:
+    regexp: '^NETCONFIG_DNS_STATIC_SERVERS=.*'
+    line: "NETCONFIG_DNS_STATIC_SERVERS={{ host_info[inventory_hostname]['public']['dns'] }}"
+    path: "/etc/sysconfig/network/config"
+    state: present
+  when: host_info[inventory_hostname]['public']['dns'] is defined
+
 - name: Configure routes on SUSE
   template:
     src: "{{ installer_type }}/{{ ansible_os_family | lower }}.routes.j2"
index 3eddce4..f9e4d8d 100644 (file)
@@ -32,5 +32,8 @@ iface {{ item.name }} inet static
 {% if item.network is defined and item.network.gateway is defined %}
     gateway {{ item.network.gateway | ipaddr('address') }}
 {% endif %}
+{% if item.network is defined and item.network.dns is defined %}
+    dns-nameservers {{ item.network.dns }}
+{% endif %}
 
 {% endif %}
index fa95776..3a51eb8 100644 (file)
@@ -17,3 +17,10 @@ STP=off
 {% if item.network is defined %}
 IPADDR={{ item.network.address }}
 {% endif %}
+{% if item.network is defined and item.network.gateway is defined %}
+GATEWAY="{{ host_info[inventory_hostname]['public']['gateway'] | ipaddr('address') }}"
+{% endif %}
+{% if item.network is defined and item.network.dns is defined %}
+DNS="{{ host_info[inventory_hostname]['public']['dns'] }}"
+{% endif %}
+{% endif %}
index 0238bae..4d743cd 100644 (file)
@@ -25,7 +25,7 @@ idf:
       network: 192.168.122.0
       mask: 24
       gateway: 192.168.122.1
-      dns: 8.8.8.8
+      dns: 192.168.122.1
     private:
       interface: 3
       network: 172.29.244.0