Ask Your Question
0

"UserData" Property in Heat Template is not triggered

asked 2013-08-19 05:55:18 -0500

Bhojaraj gravatar image

updated 2013-08-21 04:43:35 -0500

I am using below Heat template for creation of EC2 instance. The EC2 instance is successfully created but the commands/script defined in the "UserData" property is not executed. What triggers this property? I am not able to see the commands output in the VM instance after login. I am using default cirros image for VM creation on UBUNTU. The path that is required to be in the UserData - /opt/aws/bin/cfn-init - is not created. How do we install this?

{ "AWSTemplateFormatVersion" : "2010-09-09",

"Description" : "AWS CloudFormation Sample Template WordPress_Single_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.",

"Parameters" : {

"InstanceType" : {
  "Description" : "EC2 instance type",
  "Type" : "String",
  "Default" : "m1.small",
  "AllowedValues" : [ "m1.tiny", "m1.small", "m1.medium", "m1.large", "m1.xlarge" ],
  "ConstraintDescription" : "must be a valid EC2 instance type."
},  

"KeyName" : {
  "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
  "Type" : "String"
}

},

"Resources" : {

"network": {
  "Type": "OS::Quantum::Net",
  "Properties": {
    "name": "Heat Network for EC2 Instance"
  }
},

"subnet": {
  "Type": "OS::Quantum::Subnet",
  "Properties": {
    "network_id": { "Ref" : "network" },
    "ip_version": 4,
    "cidr": "192.168.1.0/24",
    "allocation_pools": [{"start": "192.168.1.3", "end": "192.168.1.20"}]
  }
},   

"NewEC2Instance": {
  "Type": "AWS::EC2::Instance",
  "Metadata" : {
    "AWS::CloudFormation::Init" : {
          "configSets" : {
              "ascending" : [ "config1" , "config2" ],
              "descending" : [ "config2" , "config1" ]
          },
          "config1" : {
              "commands" : {
                  "test" : {
                      "command" : "sudo echo \"I come from RTOSS1\" > test6.txt",
                      "env" : { "CFNTEST" : "I come from config1." },
                      "cwd" : "~"
                  }
              }
          },
          "config2" : {
              "commands" : {
                  "test" : {
                      "command" : "sudo echo \"I come from RTOSS2\" > test7.txt",
                      "env" : { "CFNTEST" : "I come from config2" },
                      "cwd" : "~"
                  }
              }
          }
    }  
  },
  "Properties": {
    "ImageId" : "62f2fcf4-3ddf-4557-8572-8ebcf949a69d",
    "InstanceType"   : { "Ref" : "InstanceType" },
    "KeyName"        : { "Ref" : "KeyName" },
    "UserData": {
        "Fn::Base64": "#!/bin/sh\n/opt/aws/bin/cfn-init -c ascending -s HeatTemplateStack -r NewEC2Instance\n"
    }
  }
}

},

"Outputs" : {
"Instance" : { "Value" : { "Ref" : "NewEC2Instance" } } } }

Please let me know incase required any other information.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-08-26 12:52:13 -0500

steven.dake gravatar image

updated 2013-08-26 12:52:31 -0500

user data is expected by the heat-cfn tools and cloudinit. The cirros image has neither. Please use an appropriate image such as those here: http://fedorapeople.org/groups/heat/prebuilt-jeos-images/ .

edit flag offensive delete link more

Comments

Thanks a lot Steven for your comments. Now commands/script defined in the "UserData" property is executed and able to see the output :) But Fedora EC2 instance asking for default username and password to login. May I know what the default username and password ? Able to login through VM through recovery mode where it connect through root user. Another issue is NOT able to connect external network from the VM and eth0 port is also not creating. Seems as I am not able to login it's not showing the etho port and IPaddress. But when using Cirris image able to see eth0 port and able to connect extrenal network from VM.

Bhojaraj gravatar imageBhojaraj ( 2013-09-04 08:06:17 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2013-08-19 05:55:18 -0500

Seen: 1,744 times

Last updated: Aug 26 '13