Quote strings in bash populated YAML files.

Quoting is hard.  When writing strings into YAML files, wrap them in single quotes.  Also escape any embedded single quotes in those strings via a double signle quote ('').
This commit is contained in:
Joe Beda 2014-12-16 15:16:59 -08:00
parent 8ba169f6a4
commit 2fc02cb06a
5 changed files with 36 additions and 29 deletions

View File

@ -20,11 +20,11 @@
mkdir -p /srv/salt-overlay/pillar mkdir -p /srv/salt-overlay/pillar
cat <<EOF >/srv/salt-overlay/pillar/cluster-params.sls cat <<EOF >/srv/salt-overlay/pillar/cluster-params.sls
node_instance_prefix: $NODE_INSTANCE_PREFIX node_instance_prefix: '$(echo "$NODE_INSTANCE_PREFIX" | sed -e "s/'/''/g")'
portal_net: $PORTAL_NET portal_net: '$(echo "$PORTAL_NET" | sed -e "s/'/''/g")'
enable_node_monitoring: $ENABLE_NODE_MONITORING enable_node_monitoring: '$(echo "$ENABLE_NODE_MONITORING" | sed -e "s/'/''/g")'
enable_node_logging: $ENABLE_NODE_LOGGING enable_node_logging: '$(echo "$ENABLE_NODE_LOGGING" | sed -e "s/'/''/g")'
logging_destination: $LOGGING_DESTINATION logging_destination: '$(echo "$LOGGING_DESTINATION" | sed -e "s/'/''/g")'
EOF EOF
mkdir -p /srv/salt-overlay/salt/nginx mkdir -p /srv/salt-overlay/salt/nginx

View File

@ -19,7 +19,9 @@ sed -i -e "\|^deb.*http://ftp.debian.org/debian| s/^/#/" /etc/apt/sources.list.d
# Prepopulate the name of the Master # Prepopulate the name of the Master
mkdir -p /etc/salt/minion.d mkdir -p /etc/salt/minion.d
echo "master: $MASTER_NAME" > /etc/salt/minion.d/master.conf cat <<EOF >/etc/salt/minion.d/master.conf
master: '$(echo "$MASTER_NAME" | sed -e "s/'/''/g")'
EOF
cat <<EOF >/etc/salt/minion.d/log-level-debug.conf cat <<EOF >/etc/salt/minion.d/log-level-debug.conf
log_level: debug log_level: debug

View File

@ -20,7 +20,9 @@ sed -i -e "\|^deb.*http://ftp.debian.org/debian| s/^/#/" /etc/apt/sources.list.d
# Prepopulate the name of the Master # Prepopulate the name of the Master
mkdir -p /etc/salt/minion.d mkdir -p /etc/salt/minion.d
echo "master: $MASTER_NAME" > /etc/salt/minion.d/master.conf cat <<EOF >/etc/salt/minion.d/master.conf
master: '$(echo "$MASTER_NAME" | sed -e "s/'/''/g")'
EOF
cat <<EOF >/etc/salt/minion.d/log-level-debug.conf cat <<EOF >/etc/salt/minion.d/log-level-debug.conf
log_level: debug log_level: debug
@ -32,7 +34,7 @@ cat <<EOF >/etc/salt/minion.d/grains.conf
grains: grains:
roles: roles:
- kubernetes-pool - kubernetes-pool
cbr-cidr: $MINION_IP_RANGE cbr-cidr: '$(echo "$MINION_IP_RANGE" | sed -e "s/'/''/g")'
cloud: gce cloud: gce
EOF EOF
@ -51,7 +53,7 @@ fi
if [[ -n "{DOCKER_OPTS}" ]]; then if [[ -n "{DOCKER_OPTS}" ]]; then
cat <<EOF >>/etc/salt/minion.d/grains.conf cat <<EOF >>/etc/salt/minion.d/grains.conf
docker_opts: $DOCKER_OPTS docker_opts: '$(echo "$DOCKER_OPTS" | sed -e "s/'/''/g")'
EOF EOF
fi fi

View File

@ -62,17 +62,19 @@ done
# Update salt configuration # Update salt configuration
mkdir -p /etc/salt/minion.d mkdir -p /etc/salt/minion.d
echo "master: $MASTER_NAME" > /etc/salt/minion.d/master.conf cat <<EOF >/etc/salt/minion.d/master.conf
master: '$(echo "$MASTER_NAME" | sed -e "s/'/''/g")'
EOF
cat <<EOF >/etc/salt/minion.d/grains.conf cat <<EOF >/etc/salt/minion.d/grains.conf
grains: grains:
node_ip: $MASTER_IP node_ip: '$(echo "$MASTER_IP" | sed -e "s/'/''/g")'
master_ip: $MASTER_IP master_ip: '$(echo "$MASTER_IP" | sed -e "s/'/''/g")'
publicAddressOverride: $MASTER_IP publicAddressOverride: '$(echo "$MASTER_IP" | sed -e "s/'/''/g")'
network_mode: openvswitch network_mode: openvswitch
networkInterfaceName: eth1 networkInterfaceName: eth1
etcd_servers: $MASTER_IP etcd_servers: '$(echo "$MASTER_IP" | sed -e "s/'/''/g")'
api_servers: $MASTER_IP api_servers: '$(echo "$MASTER_IP" | sed -e "s/'/''/g")'
cloud: vagrant cloud: vagrant
cloud_provider: vagrant cloud_provider: vagrant
roles: roles:
@ -81,11 +83,11 @@ EOF
mkdir -p /srv/salt-overlay/pillar mkdir -p /srv/salt-overlay/pillar
cat <<EOF >/srv/salt-overlay/pillar/cluster-params.sls cat <<EOF >/srv/salt-overlay/pillar/cluster-params.sls
portal_net: $PORTAL_NET portal_net: '$(echo "$PORTAL_NET" | sed -e "s/'/''/g")'
cert_ip: $MASTER_IP cert_ip: '$(echo "$MASTER_IP" | sed -e "s/'/''/g")'
enable_node_monitoring: $ENABLE_NODE_MONITORING enable_node_monitoring: '$(echo "$ENABLE_NODE_MONITORING" | sed -e "s/'/''/g")'
enable_node_logging: $ENABLE_NODE_LOGGING enable_node_logging: '$(echo "$ENABLE_NODE_LOGGING" | sed -e "s/'/''/g")'
logging_destination: $LOGGING_DESTINATION logging_destination: '$(echo "$LOGGING_DESTINATION" | sed -e "s/'/''/g")'
EOF EOF
# Configure the salt-master # Configure the salt-master
@ -155,7 +157,6 @@ rest_cherrypy:
webhook_disable_auth: True webhook_disable_auth: True
EOF EOF
# Install Salt Master # Install Salt Master
# #
# -M installs the master # -M installs the master

View File

@ -40,22 +40,24 @@ done
# Let the minion know who its master is # Let the minion know who its master is
mkdir -p /etc/salt/minion.d mkdir -p /etc/salt/minion.d
echo "master: $MASTER_NAME" > /etc/salt/minion.d/master.conf cat <<EOF >/etc/salt/minion.d/master.conf
master: '$(echo "$MASTER_NAME" | sed -e "s/'/''/g")'
EOF
# Our minions will have a pool role to distinguish them from the master. # Our minions will have a pool role to distinguish them from the master.
cat <<EOF >/etc/salt/minion.d/grains.conf cat <<EOF >/etc/salt/minion.d/grains.conf
grains: grains:
network_mode: openvswitch network_mode: openvswitch
node_ip: $MINION_IP node_ip: '$(echo "$MINION_IP" | sed -e "s/'/''/g")'
etcd_servers: $MASTER_IP etcd_servers: '$(echo "$MASTER_IP" | sed -e "s/'/''/g")'
api_servers: $MASTER_IP api_servers: '$(echo "$MASTER_IP" | sed -e "s/'/''/g")'
networkInterfaceName: eth1 networkInterfaceName: eth1
apiservers: $MASTER_IP apiservers: '$(echo "$MASTER_IP" | sed -e "s/'/''/g")'
roles: roles:
- kubernetes-pool - kubernetes-pool
- kubernetes-pool-vagrant - kubernetes-pool-vagrant
cbr-cidr: $MINION_IP_RANGE cbr-cidr: '$(echo "$MINION_IP_RANGE" | sed -e "s/'/''/g")'
minion_ip: $MINION_IP minion_ip: '$(echo "$MINION_IP" | sed -e "s/'/''/g")'
EOF EOF
# we will run provision to update code each time we test, so we do not want to do salt install each time # we will run provision to update code each time we test, so we do not want to do salt install each time