issue with heat template cloud config

asked 2020-04-16 10:42:06 -0500

akarki gravatar image

Hi, I am using a heat template to deploy VM.

My Template:

> heat_template_version: 2015-10-15
> description: Launch a basic instance
> with CirrOS image using the
>              ``m1.tiny`` flavor, ``mykey`` key,  and one network.
> 
> parameters:   NetID:
>     type: string
>     description: Network ID to use for the instance.   RtspIP:
>     type: string
>     description: RTSPAPPSERVER IP to use for the instance.   User:
>     type: string   Pass:
>     type: string   AppServerID:
>     type: string   MobileIP:
>     type: string   MobilePort:
>     type: string resources:   server:
>     type: OS::Nova::Server
>     properties:
>             # image: rtsp4
>       image: rtsp3
>       flavor: m1.medium
>       key_name: mycontrollerKey
>       networks:
>       - network: { get_param: NetID }
>       user_data_format: RAW
>       user_data:
>         get_resource: server_init
> 
>   server_init:
>     type: OS::Heat::MultipartMime
>     properties:
>       parts:
>       - config: {get_resource: boot_script}
>       - config: {get_resource: boot_config}   boot_script:
>     type: OS::Heat::SoftwareConfig
>     properties:
>       group: ungrouped
>       config:
>         str_replace:
>                 template: |
>                         #!/bin/bash
>                         mkdir -p /tmp/abc
>                         sh -c 'echo ubuntu:hsc321 | chpasswd'
>                         touch /tmp/rtspdata
>                         echo $RtspIP $User $Pass $appPath>/tmp/rtspdata
>                         bash /home/ubuntu/check_ip.sh & >
> /home/ubuntu/server_logs
>                 params:
>                         $appPath: {get_param: AppServerID}
>                         $RtspIP: {get_param: RtspIP}
>                         $User: {get_param: User}
>                         $Pass: {get_param: Pass}
>                         $MobileIP: {get_param: MobileIP}
>                         $MobilePort: {get_param: MobilePort}   boot_config:
>     type: OS::Heat::CloudConfig
>     properties:
>       cloud_config:
>         ssh_pwauth: true
>         disable_root: false
>         chpasswd:
>           list:
>             str_replace:
>               template: "ubuntu:PASSWORD"
>               params:
>                 PASSWORD: "hsc321"
>           expire: False
> 
> outputs:   instance_ip:
>     description: IP address of the instance.
>     value: { get_attr: [ server, first_address ] }

So my lab setup has already a dhcp server running...along with the openstack flat network dhcp which i created.

So Issue is sometimes my vm gets ip from lab dhcp. Hence the metadata route does not get attached hence cloud config does not get executed so passwd not set in vm that i get.

But once in a while i tend to see that vm gets ip from external dhcp but still executes cloud config. How and why?

Also how does key insertion thing always work does it on also depend on metadata. Coz my keys always tend to be inserted no matter what dhcp server is.

Also what iptables rules i can apply so that i can block the traffic from external lab dhcp..in compute or in the flow table.

Please help.

edit retag flag offensive close merge delete

Comments

I don't think metadata has anything to do with the DHCP server, except that the instance needs someIP address. By default, an instance gets metadata, including ssh keys, from http://169.254.169.254.

Bernd Bausch gravatar imageBernd Bausch ( 2020-04-16 10:49:25 -0500 )edit

So if my vm gets ip and routes from internal dhcp it has metadata rouet in it... but with external dhcp..sincce it is for lab..not metadat route gets inserted in vm. Hence no cloud config gets executed.(for most of the times that is)

akarki gravatar imageakarki ( 2020-04-16 11:10:18 -0500 )edit