cloudbase / cloudbase-init

Cross-platform instance initialization
http://openstack.org
Apache License 2.0
421 stars 149 forks source link

cloudbase-init config script works inconsistently using azure shared gallery image and azure java client #40

Open bhavyaSharma-appD opened 4 years ago

bhavyaSharma-appD commented 4 years ago

I have created a windows 2012 R2 azure image with cloudbase-init installed. My intention is to run a script while starting any new VM instance using this image. My cloud config script contains powershell script basically starting with #ps1sysnative. This has been working fine for a while now.

I have moved my azure base image to shared image gallery. Now, when I am creating an instance using the complete image url of latest image present in shared image gallery, I run into one issue. I am passing the same cloud config script. But, what is happening is that I can start new machine with cloud config script executed during startup while doing so using azure cli but while making create instance call using azure java client (basically method https://docs.microsoft.com/en-us/java...) and passing cloud config using https://docs.microsoft.com/en-us/java..., at time cloudbase-init runs the cloud config powershell script but after a while it is not running this script, that custom data is getting dumped into azure machine as customdata.bin. All cofiguration is same and the same flow works if I give the base image id and not the one present in shared gallery.

Cloud-config script is something like this:

#ps1_sysnative

$example = ‘test’

(Get-Content -Path C:\testData) |
  ForEach-Object {$_ -Replace ‘{example}‘, $example} |
    Set-Content -Path C:\testData

Not sure why this weird behaviour when using shared gallery image and azure java client. I am not making any changes but running into this weird behaviour. Kindly assist.

bhavyaSharma-appD commented 4 years ago

Any update on this?

ader1990 commented 4 years ago

Hello @bhavyaSharma-appD ,

Please provide any information that could help debug the issue, like the cloudbase-init config files and logs.

It would be great if you could describe how the image was created (what tools), if the image was sysprepped what is your XY goal (https://en.wikipedia.org/wiki/XY_problem).

Thank you, Adrian Vladu