Fix idempotence issue in dns role

Docker_container module was called twice: in a taks
'Start dns server container' and then as a handler
but there was a divergent set o parameters for the
module in them. This had the efect of the container
being started by the means of the task itself but
immediately after it was killed and started again
by the handler because it had different set of
arguments for the module. The fix is to include the
handler itself as a task so the whole run is idempotent.

Change-Id: I9078f9dfe5894d94d4b6a9e44411f034508992e7
Issue-ID: OOM-1845
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
diff --git a/ansible/roles/dns/tasks/main.yml b/ansible/roles/dns/tasks/main.yml
index 3eba9fd..121ee0c 100644
--- a/ansible/roles/dns/tasks/main.yml
+++ b/ansible/roles/dns/tasks/main.yml
@@ -8,7 +8,7 @@
   template:
     src: simulated_hosts.j2
     dest: "{{ app_data_path }}/cfg/simulated_hosts"
-  notify: Restart dns server container
+  notify: Run dns server container
 
 - name: Load dns server container
   docker_image:
@@ -16,21 +16,13 @@
     load_path: "{{ infra_images_path }}/{{ dns_server_image_tar }}"
     state: present
     timeout: 120
-  notify: Restart dns server container
+  notify: Run dns server container
 
-- name: Start dns server container
-  docker_container:
-    name: dns-server
-    network_mode: host
-    image: "{{ dns_server_image }}"
-    command: -H /simulated_hosts --log-facility=-
-    capabilities: NET_ADMIN
-    dns_servers:
-      - 127.0.0.1
-    volumes:
-      - "{{ app_data_path }}/cfg/simulated_hosts:/simulated_hosts:ro"
-    ports:
-      - "53:53/tcp"
-      - "53:53/udp"
-    state: started
-    restart_policy: unless-stopped
+- name: Enumerate running containers
+  docker_list_containers:
+  register: containers_list
+
+- name: Ensure dns container is running
+  command: /bin/true
+  notify: Run dns server container
+  when: "'dns-server' not in containers_list.containers"