Add state to pull docker image

Add independent state to pull docker images,
so it can be executed separately from whole
docker.client state. In pipelines we can setup
parallel run for this state to make sure that
docker images are successfully pulled on each node.

Change-Id: Ic3417a97e3d34fb7c8bc695232eac24ad8cbae47
Related-bug: #PROD-25515 (PROD:25515)
diff --git a/.kitchen.yml b/.kitchen.yml
index 87d65d9..9b01e51 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -65,6 +65,11 @@
 
 suites:
 
+  - name: client_images
+    provisioner:
+      pillars-from-files:
+        docker.sls: tests/pillar/client_images.sls
+
   - name: client_compose
     provisioner:
       pillars-from-files:
diff --git a/docker/client/images.sls b/docker/client/images.sls
new file mode 100644
index 0000000..762a9e9
--- /dev/null
+++ b/docker/client/images.sls
@@ -0,0 +1,28 @@
+{% from "docker/map.jinja" import client with context %}
+{%- if client.get('enabled', False) and client.images is defined %}
+
+docker_client:
+  pkg.installed:
+    - names: {{ client.pkgs }}
+
+{%- for image in client.get('images', []) %}
+{{ image }}_image:
+  {%- if grains['saltversioninfo'] >= [2017, 7, 0] %}
+  docker_image.present:
+  {%- else %}
+  dockerng.image_present:
+  {%- endif %}
+    - name: {{ image }}
+    - force: True
+    {%- if grains.get('noservices') %}
+    - onlyif: /bin/false
+    {%- endif %}
+    - require:
+      - pkg: docker_client
+    - retry:
+        attempts: 5
+        until: True
+        interval: 5
+{%- endfor %}
+
+{%- endif %}
diff --git a/docker/client/init.sls b/docker/client/init.sls
index d80dc11..09079ae 100644
--- a/docker/client/init.sls
+++ b/docker/client/init.sls
@@ -5,6 +5,9 @@
   {%- if pillar.docker.client.network is defined %}
   - docker.client.network
   {%- endif %}
+  {%- if pillar.docker.client.images is defined %}
+  - docker.client.images
+  {%- endif %}
   {%- if pillar.docker.client.container is defined %}
   - docker.client.container
   {%- endif %}
diff --git a/tests/pillar/client_images.sls b/tests/pillar/client_images.sls
new file mode 100644
index 0000000..69e4b60
--- /dev/null
+++ b/tests/pillar/client_images.sls
@@ -0,0 +1,9 @@
+docker:
+  host:
+    enabled: true
+    options:
+      bip: 192.168.0.1/24
+  client:
+    enabled: true
+    images:
+      - jenkins:2.7.1
\ No newline at end of file