Refactor key-fetch

https://mirantis.jira.com/browse/PROD-31000

Change-Id: Id28338cbc39a67b0291c68a03e982a128a968138
diff --git a/config-drive/master_config.yaml b/config-drive/master_config.yaml
index 240b717..6ab1467 100644
--- a/config-drive/master_config.yaml
+++ b/config-drive/master_config.yaml
@@ -29,6 +29,7 @@
       export FORMULAS=${FORMULAS:-"salt-formula-*"}
       export SALT_OPTS=${SALT_OPTS:-"-l debug -t 30 --retcode-passthrough --no-color"}
       export CFG_BOOTSTRAP_DRIVE_URL=${CFG_BOOTSTRAP_DRIVE_URL:-""}
+      export WGET_OPTS=${WGET_OPTS:-"--progress=dot:mega --waitretry=15 --retry-connrefused"}
 
 master_config:
   - &master_config |
@@ -53,8 +54,11 @@
     function process_formulas(){
       local RECLASS_ROOT=${RECLASS_ROOT:-/srv/salt/reclass/}
       local FORMULAS_PATH=${FORMULAS_PATH:-/usr/share/salt-formulas}
+      local _tname="/tmp/archive-salt-formulas_${RANDOM}.key"
 
-      curl -s ${MCP_SALT_REPO_KEY} | apt-key add -
+      wget ${WGET_OPTS} -O ${_tname} ${MCP_SALT_REPO_KEY}
+      apt-key add ${_tname}
+
       echo "${MCP_SALT_REPO}" > /etc/apt/sources.list.d/mcp_salt.list
       if [[ "${ENABLE_MCP_SALT_REPO_UPDATES}" == "true" ]] ; then
         echo "${MCP_SALT_REPO_UPDATES}" >> /etc/apt/sources.list.d/mcp_salt.list
@@ -220,8 +224,7 @@
     if [[ -n "${CFG_BOOTSTRAP_DRIVE_URL}" ]]; then
       echo "CFG_BOOTSTRAP_DRIVE_URL detected,downloading..."
       _tname="cfg01_${RANDOM}.iso"
-      _wget_opts="--progress=dot:mega --waitretry=15 --retry-connrefused"
-      wget ${_wget_opts} -O /${_tname} "${CFG_BOOTSTRAP_DRIVE_URL}"
+      wget ${WGET_OPTS} -O /${_tname} "${CFG_BOOTSTRAP_DRIVE_URL}"
       mount -o loop /${_tname} /mnt
     else
       mount $(blkid -t TYPE=iso9660 -o device) /mnt