Fix docker config handling in offline installer 52/75452/10
authorMichal Zegan <m.zegan@samsung.com>
Fri, 4 Jan 2019 13:20:03 +0000 (14:20 +0100)
committerMichal Zegan <m.zegan@samsung.com>
Thu, 17 Jan 2019 14:19:21 +0000 (15:19 +0100)
This fixes adding of dns address to
/etc/docker/daemon.json to always use infra's ip address
instead of possibly using it's hostname.
Also similar change is done in handling of
/etc/resolv.conf in infrastructure.yml.
Ip address is specified by the "cluster_ip" variable placed on a host.
Inventory specifies ip for everything except resource server (just for consistency).

Change-Id: I2baa3f4c7d69b8dff109b5f8ae984134caf2af7d
Issue-ID: OOM-1573
Signed-off-by: Michal Zegan <m.zegan@samsung.com>
ansible/docker/Dockerfile
ansible/infrastructure.yml
ansible/inventory/hosts.yml
ansible/roles/docker/tasks/main.yml

index b017270..4cefa8b 100644 (file)
@@ -24,6 +24,7 @@ RUN apk --no-cache update \
 && pip3 install --no-cache-dir \
   ansible==$ansible_version \
   jmespath \
+  netaddr \
 && apk del build-dependencies && rm -rf /var/cache/apk/*
 
 ENV ANSIBLE_HOST_KEY_CHECKING false
index 789f871..709a351 100644 (file)
@@ -4,7 +4,7 @@
   tasks:
     - name: Setup resolv.conf
       lineinfile:
-        line: "nameserver {{ hostvars[groups.infrastructure[0]].ansible_host }}"
+        line: "nameserver {{ hostvars[groups.infrastructure[0]].cluster_ip }}"
         path: /etc/resolv.conf
         state: present
         insertbefore: BOF
index f11ef7b..a29072c 100644 (file)
@@ -20,12 +20,16 @@ all:
       hosts:
         infrastructure-server:
           ansible_host: 10.8.8.13
+          #IP used for communication between infra and kubernetes nodes, must be specified.
+          cluster_ip: 10.8.8.13
 
     # This is group of hosts which are/will be part of Kubernetes cluster.
     kubernetes:
       hosts:
         kubernetes-node-1:
           ansible_host: 10.8.8.19
+          #ip of the node that it uses for communication with k8s cluster.
+          cluster_ip: 10.8.8.19
 
     nfs-server:
       hosts:
index 9851d4d..09e790a 100644 (file)
@@ -20,7 +20,7 @@
   json_add:
     path: /etc/docker/daemon.json
     key: dns
-    value: "{{ hostvars[groups.infrastructure[0]].ansible_default_ipv4.address }}"
+    value: "{{ hostvars[groups.infrastructure[0]].cluster_ip }}"
   notify:
     - Restart Docker