Add retry for gpg import

  * Gpg key's servers may stuck randomly
  * refresh tests

Change-Id: I000358fb8f2adbdcbe9c3b887d0bc0dc8155ef35
Closes-Bug: PROD-21387 (PROD:21387)
diff --git a/aptly/server/init.sls b/aptly/server/init.sls
index 5083035..e3e7d6a 100644
--- a/aptly/server/init.sls
+++ b/aptly/server/init.sls
@@ -179,6 +179,13 @@
   - require:
     - file: gpg_pub_key
     - cmd: import_gpg_priv_key
+{%- if grains['saltversioninfo'][0] >= 2017 and grains['saltversioninfo'][1] >= 7 %}
+  - retry:
+      attempts: 5
+      until: True
+      interval: 5
+      splay: 2
+{%- endif %}
 
 import_gpg_priv_key:
   cmd.run:
@@ -190,6 +197,13 @@
     - file: gpg_priv_key
   - require_in:
     - cmd: aptly_installed
+{%- if grains['saltversioninfo'][0] >= 2017 and grains['saltversioninfo'][1] >= 7 %}
+  - retry:
+      attempts: 5
+      until: True
+      interval: 5
+      splay: 2
+{%- endif %}
 
 {%- endif %}
 
diff --git a/aptly/server/mirrors.sls b/aptly/server/mirrors.sls
index 8944522..4e31e9d 100644
--- a/aptly/server/mirrors.sls
+++ b/aptly/server/mirrors.sls
@@ -55,6 +55,14 @@
   - require_in:
     - cmd: aptly_{{ mirror_name }}_mirror
   {%- endif %}
+{%- if grains['saltversioninfo'][0] >= 2017 and grains['saltversioninfo'][1] >= 7 %}
+  - retry:
+      attempts: 5
+      until: True
+      interval: 5
+      splay: 2
+{%- endif %}
+
 
 {%- endfor %}