Search code examples
openstackopenstack-novaopenstack-heat

Unable to run a script in HEAT/HOT Template


I'm unable to execute a script using the heat template and request some inputs.

OpenStack --> Deploying an AWS Instance

My HEAT template --

heat_template_version: 2013-05-23

description: >
  Created 4/20/17 by [email protected]. For Cloud admin@MSS Adaptive Security

parameters:
  flavor:
    type: string
    description: 'Flavor to be used for compute instance'
  key_name:
    type: string
    description: 'For most clouds, the name of the key-pair to be used for the compute instance; for VMware clouds, the contents of the public SSH key for the compute instance'
  availability_zone1:
    type: string
    description: 'Name of availability zone in which to create the instance'
    default: 'nova'
  network-id__for__Itaas_testing:
    type: string
    description: 'Generated to reference ''Itaas_testing'' network.'
    default: 'vpc-f3f24490'
  subnet_id_subnet-faf1b19a:
    type: string
    description: 'Generated to reference subnet ''itaas_Private subnet''.'
    default: 'subnet-faf1b19a'
parameter_groups:
    - { label: 'Image Parameters', parameters: [flavor, key_name] }
    - { label: 'Network Parameters', parameters: [availability_zone1, network-id__for__Itaas_testing, subnet_id_subnet-faf1b19a] }
resources:
## REFERENCE {"Itaas_testing":{"type": "OS::Neutron::Net", "properties": {"network_id": "vpc-f3f24490", "external":"false", "subnets": [{"cidr":"10.0.0.0\/24","availability_zone":"us-west-1a","name":"itaas_Public subnet","id":"subnet-4af4b42a"},{"cidr":"10.0.4.0\/28","availability_zone":"us-west-1a","name":"itaas_Private subnet","id":"subnet-faf1b19b"}] }}}

  RHEL-7_0_HVM_GA-20141017-x86_64-1-Hourly2-GP2:
    type: OS::Nova::Server
    properties:
      networks:
          - port: { get_resource: RHEL-7_0_HVM_GA-20141017-x86_64-1-Hourly2-GP2__to__Itaas_testing__port  }
      name: "RHEL-7_0_HVM_GA-20141017-x86_64-1-Hourly2-GP2"
      image: "ami-33cdd876" # RHEL-7.0_HVM_GA-20141017-x86_64-1-Hourly2-GP2
      flavor: { get_param: flavor }
      key_name: { get_param: key_name }
      availability_zone: { get_param: availability_zone1 }
      metadata: 
        "__os_type__" : "Linux"
      user_data: https://raw.githubusercontent.com/AnishAnil/Learn-git/master/test.sh

  RHEL-7_0_HVM_GA-20141017-x86_64-1-Hourly2-GP2__to__Itaas_testing__port:
    type: OS::Neutron::Port
    properties:
      security_groups:
          - sg-1869137f  # sg-1869137f(itaas_testing_security_group_any_any_any)  
      network_id: { get_param: network-id__for__Itaas_testing }
      replacement_policy: AUTO   #TODO remove this if using HEAT version Icehouse!
      fixed_ips:
        - subnet: { get_param: subnet_id_subnet-faf1b19e }

outputs:
  blueprint_url:
    description: Blueprint Origin URL
    value:  https://ABCD:8443/landscaper/view/projects?open=a%40gmail.com_8caf420f_f24a_4c4d_83f8_cb9835d7b734-OrionContent/default/Adaptive_Security/ITSAAS_Baston.yml

The script file mentioned contains the following data:

#!/bin/sh
sudo mkdir /tmp/A1

Solution

  • You can not use directly an URL in the field user_data. Instead, use the function get_file to load a content:

    user_data: { get_file: https://raw.githubusercontent.com/AnishAnil/Learn-git/master/test.sh }
    

    Check the Heat Orchestration Templates (HOT) specification.