← Back to team overview

openstack team mailing list archive

Problems with Fn::Join

 

Hi,

We are seeing a new behavior with Fn::Join in user-data block that makes our script fail to run. Previous behavior was that no white space nor line breaks were inserted after a coma (',') or line ends. But now it's inserting white space plus line break after ',' separated elements... Do you have any idea why?
Thanks
Patrick

_Exemple_:

"Fn::Join":[
                     "\n",
                     [
                        "#!/bin/bash -v",
                        "# Helper function",
                        "function error_exit\n",
                        "{\n",
" /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '", { "Ref" : "BatchNodeWaitHandle" }, "'\n",
                        "  exit 1\n",
                        "}\n",

                        "# Flush iptables's default rules",
                        "/sbin/iptables -F",
                        "/sbin/iptables -X",
                        "# prepare for packages install",
                        "yum update -y",
                        "yum upgrade -y",
                        "export http_proxy=ecfrec.frec.bull.fr:8080",
"export no_proxy=127.0.0.1,localhost,.amg.net.pl,169.254.169.254,10.197.217.62",

"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" },
                        " -r BatchNode ",
                        " --region ", { "Ref" : "AWS::Region" },
" || error_exit 'Failed to run cfn-init for BatchNode'\n",

                        "rpm -Uvh http://rbel.frameos.org/rbel6";,
                        "#install rubygems",
                        "cd /opt",
                        "tar zxf rubygems-1.8.10.tgz",
                        "cd rubygems-1.8.10",
                        "ruby setup.rb --no-format-executable",
                        "gem install chef --no-ri --no-rdoc",
"/opt/aws/bin/cfn-signal -e $? '", { "Ref":"BatchNodeWaitHandle" }, "'"
                     ]
                  ]

_Results in broken __cfn-userdata script_

#!/bin/bash -v
# Helper function

function error_exit

{

  /opt/aws/bin/cfn-signal -e 1 -r "$1" '
http://172.16.1.1:8002/stacks/1a7b8501-e117-4cf8-9838-416446a43fed/resources/BatchNodeWaitHandle
'

  exit 1

}


# Flush iptables's default rules
/sbin/iptables -F
/sbin/iptables -X
# prepare for packages install
yum update -y
yum upgrade -y
export http_proxy=ecfrec.frec.bull.fr:8080
export no_proxy=127.0.0.1,localhost,.amg.net.pl,169.254.169.254,10.197.217.62
/opt/aws/bin/cfn-init -s
skeleton
 -r BatchNode
 --region
ap-southeast-1
 || error_exit 'Failed to run cfn-init for BatchNode'
rpm -Uvh http://rbel.frameos.org/rbel6
#install rubygems
cd /opt
tar zxf rubygems-1.8.10.tgz
cd rubygems-1.8.10
ruby setup.rb --no-format-executable
gem install chef --no-ri --no-rdoc
/opt/aws/bin/cfn-signal -e $? '
http://172.16.1.1:8002/stacks/1a7b8501-e117-4cf8-9838-416446a43fed/resources/BatchNodeWaitHandle
'
touch /var/lib/cloud/instance/provision-finished


Follow ups