Add possibility to override some environment variables

Add possibility to use custom 'master_environment_override'
and 'mirror_environment_override' files, to avoid sed-ing the
user-data files.

Related issue: https://mirantis.jira.com/browse/PROD-23809

Change-Id: I664a200358f98e35ceb28267dc40c4974778ba30
diff --git a/config-drive/master_config.yaml b/config-drive/master_config.yaml
index 76ecf72..9adf894 100644
--- a/config-drive/master_config.yaml
+++ b/config-drive/master_config.yaml
@@ -6,23 +6,24 @@
     path: /etc/cloud/master_environment
     permissions: '0644'
     content: |
-      export SALT_MASTER_DEPLOY_IP="172.16.164.15"
-      export SALT_MASTER_MINION_ID="cfg01.deploy-name.local"
-      export DEPLOY_NETWORK_GW="172.16.164.1"
-      export DEPLOY_NETWORK_NETMASK="255.255.255.192"
-      export DEPLOY_NETWORK_MTU="1500"
-      export DNS_SERVERS="8.8.8.8"
-      export http_proxy=""
-      export https_proxy=""
-      export PIPELINES_FROM_ISO="true"
-      export PIPELINE_REPO_URL="https://github.com/Mirantis"
-      export MCP_VERSION="stable"
-      export MCP_SALT_REPO_KEY="http://apt.mirantis.com/public.gpg"
-      export MCP_SALT_REPO_URL="http://apt.mirantis.com/xenial"
-      export MCP_SALT_REPO="deb [arch=amd64] $MCP_SALT_REPO_URL $MCP_VERSION salt"
-      export FORMULAS="salt-formula-*"
-      export SALT_OPTS="-l debug -t 10 --retcode-passthrough --no-color"
-      export CFG_BOOTSTRAP_DRIVE_URL=""
+      [ -f /etc/cloud/master_environment_override ] && . /etc/cloud/master_environment_override
+      export SALT_MASTER_DEPLOY_IP=${SALT_MASTER_DEPLOY_IP:-"172.16.164.15"}
+      export SALT_MASTER_MINION_ID=${SALT_MASTER_MINION_ID:-"cfg01.deploy-name.local"}
+      export DEPLOY_NETWORK_GW=${DEPLOY_NETWORK_GW:-"172.16.164.1"}
+      export DEPLOY_NETWORK_NETMASK=${DEPLOY_NETWORK_NETMASK:-"255.255.255.192"}
+      export DEPLOY_NETWORK_MTU=${DEPLOY_NETWORK_MTU:-"1500"}
+      export DNS_SERVERS=${DNS_SERVERS:-"8.8.8.8"}
+      export http_proxy=${http_proxy:-""}
+      export https_proxy=${https_proxy:-""}
+      export PIPELINES_FROM_ISO=${PIPELINES_FROM_ISO:-"true"}
+      export PIPELINE_REPO_URL=${PIPELINE_REPO_URL:-"https://github.com/Mirantis"}
+      export MCP_VERSION=${MCP_VERSION:-"stable"}
+      export MCP_SALT_REPO_KEY=${MCP_SALT_REPO_KEY:-"http://apt.mirantis.com/public.gpg"}
+      export MCP_SALT_REPO_URL=${MCP_SALT_REPO_URL:-"http://apt.mirantis.com/xenial"}
+      export MCP_SALT_REPO=${MCP_SALT_REPO:-"deb [arch=amd64] $MCP_SALT_REPO_URL $MCP_VERSION salt"}
+      export FORMULAS=${FORMULAS:-"salt-formula-*"}
+      export SALT_OPTS=${SALT_OPTS:-"-l debug -t 10 --retcode-passthrough --no-color"}
+      export CFG_BOOTSTRAP_DRIVE_URL=${CFG_BOOTSTRAP_DRIVE_URL:-""}
 master_config:
   - &master_config |
     function _post_maas_cfg() {