# e.g. app_data_path: /opt/onap
 app_data_path:
 
+# Path for tarballs with images loaded on infrastructure server
+infra_images_path: "{{ app_data_path }}/offline_data/docker_images_infra"
+
 # Path for auxiliary data in target infra server.
 # Data from resource host defined by aux_resources_filename variable is placed to this directory.
 # Currently docker images in tar format are supported (see runtime_images parameter).
 
 rancher_server_version: v1.6.22
 populate_nexus: false
 helm_bin_dir: /usr/local/bin
+vnc_server_image: consol/centos-icewm-vnc:1.4.0
+nexus3_image: sonatype/nexus3:3.15.2
+dns_server_image: andyshinn/dnsmasq:2.76
+nginx_server_image: own_nginx:2.0.0
 
--- /dev/null
+---
+# Default rule for tarball naming translation
+dns_server_image_tar: "{{ dns_server_image | regex_replace('(\\/|\\:)', '_') }}.tar"
 
 ---
-- name: Restart dnsmasq container
+- name: Restart dns server container
   docker_container:
-    name: dnsmasq
-    image: andyshinn/dnsmasq:2.76
+    name: dns-server
+    image: "{{ dns_server_image }}"
     command: -H /simulated_hosts --log-facility=-
     capabilities: NET_ADMIN
     volumes:
 
   template:
     src: simulated_hosts.j2
     dest: "{{ app_data_path }}/cfg/simulated_hosts"
-  notify: Restart dnsmasq container
+  notify: Restart dns server container
 
-- name: Load dnsmasq container
+- name: Load dns server container
   docker_image:
-    name: andyshinn/dnsmasq:2.76
-    load_path: "{{ app_data_path }}/offline_data/docker_images_infra/andyshinn_dnsmasq_2.76.tar"
+    name: "{{ dns_server_image }}"
+    load_path: "{{ infra_images_path }}/{{ dns_server_image_tar }}"
     state: present
     timeout: 120
-  notify: Restart dnsmasq container
+  notify: Restart dns server container
 
-- name: Start dnsmasq container
+- name: Start dns server container
   docker_container:
-    name: dnsmasq
+    name: dns-server
     network_mode: host
-    image: andyshinn/dnsmasq:2.76
+    image: "{{ dns_server_image }}"
     command: -H /simulated_hosts --log-facility=-
     capabilities: NET_ADMIN
     dns_servers:
 
 # By dafault no additional docker images pushed to nexus at runtime
 # but all images are pre-populated either at buildtime or at install time (populate_nexus).
 runtime_images: {}
+# Default rule for tarball naming translation
+nexus3_image_tar: "{{ nexus3_image | regex_replace('(\\/|\\:)', '_') }}.tar"
 
 
 - name: Load nexus image
   docker_image:
-    name: sonatype/nexus3
-    load_path: "{{ app_data_path }}/offline_data/docker_images_infra/sonatype_nexus3_latest.tar"
+    name: "{{ nexus3_image }}"
+    load_path: "{{ infra_images_path }}/{{ nexus3_image_tar }}"
     state: present
     timeout: 120
 
     name: nexus_network
     state: present
 
-- name: Run nexus container
+- name: Start nexus server container
   docker_container:
     name: nexus
-    image: sonatype/nexus3
+    image: "{{ nexus3_image }}"
     networks:
       - name: nexus_network
     volumes:
 
     - "{{ app_data_path }}/pkg/rhel:/srv/http/repo.infra-server/rhel:rw"
     - "{{ app_data_path }}/pkg/ubuntu/xenial:/srv/http/repo.infra-server/ubuntu/xenial:rw"
     - /var/log/nginx:/var/log/nginx:rw
+# Default rule for tarball naming translation
+nginx_server_image_tar: "{{ nginx_server_image | regex_replace('(\\/|\\:)', '_') }}.tar"
 
     src: nginx.conf.j2
     dest: "{{ app_data_path }}/cfg/nginx.conf"
 
-- name: Load nginx image
+- name: Load nginx server image
   docker_image:
-    name: own_nginx
-    load_path: "{{ app_data_path }}/offline_data/docker_images_infra/own_nginx_latest.tar"
+    name: "{{ nginx_server_image }}"
+    load_path: "{{ infra_images_path }}/{{ nginx_server_image_tar }}"
     state: present
     timeout: 120
 
     name: nexus_network
     state: present
 
-- name: Start nginx
+- name: Start nginx server container
   docker_container:
-    name: own_nginx
-    image: own_nginx
+    name: nginx-server
+    image: "{{ nginx_server_image }}"
     networks:
       - name: nexus_network
     ports: "{{ nginx.ports }}"
 
--- /dev/null
+---
+# Default rule for tarball naming translation
+vnc_server_image_tar: "{{ vnc_server_image | regex_replace('(\\/|\\:)', '_') }}.tar"
 
 ---
 - name: Load VNC server image
   docker_image:
-    name: consol/centos-icewm-vnc:latest
-    load_path: '{{ app_data_path }}/offline_data/docker_images_infra/consol_centos_icewm_vnc_latest.tar'
+    name: "{{ vnc_server_image }}"
+    load_path: "{{ infra_images_path }}/{{ vnc_server_image_tar }}"
     state: present
     timeout: 120
 
-- name: Run VNC server
+- name: Start VNC server container
   docker_container:
-    name: vnc_server
-    image: consol/centos-icewm-vnc
+    name: vnc-server
+    image: "{{ vnc_server_image }}"
     state: started
     restart_policy: unless-stopped
     ports:
 
 #
 #   COPYRIGHT NOTICE ENDS HERE
 
+VERSION="$(cat $(dirname ${0})/VERSION)"
+
 IMG_DIR="${1}"
 
 if [[ ! -e $IMG_DIR ]]; then
 
 script_dir="$(dirname ${BASH_SOURCE[0]})"
 cd "$script_dir"
-docker build -t own_nginx .
-docker -l error save -o "$IMG_DIR/own_nginx_latest.tar" "own_nginx:latest"
+docker build -t own_nginx:${VERSION} .
+docker -l error save -o "$IMG_DIR/own_nginx_${VERSION}.tar" "own_nginx:${VERSION}"
 
 
 RUN apk add --no-cache --update fcgiwrap git git-daemon spawn-fcgi
 
+ADD VERSION .
+
 COPY gitconfig /etc/
 
 CMD spawn-fcgi -M 666 -s /var/run/fcgiwrap.socket /usr/bin/fcgiwrap && \
 
 andyshinn/dnsmasq:2.76
-consol/centos-icewm-vnc:latest
+consol/centos-icewm-vnc:1.4.0
 sonatype/nexus3:3.15.2