New Question
0

Calling Metadata in a customization script

asked 2017-01-02 00:44:19 +0300

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

Hi

i am currently trying to build a customization script that pulls variables from the meta data web service during initial boot and configuration but have run into an issue that causes the process to fail with an error 0 in the Cloudbase-init logs and i am wondering if i am doing something wrong or if there is a better way to do it.

basically the powershell customization script uses a invoke-webrequest to pull the meta object from the webservice then reads it a json and i extract the branches i want later in the script. code: $request = 'http://169.254.169.254/openstack/latest/meta_data.json' $meta = Invoke-WebRequest $request | ConvertFrom-Json | select -expand meta

from within a deployed VM this works as expected however during a instance build i have seen the following: Invoke-WebRequest : The response content cannot be parsed because the Internet \r\nExplorer engine is not available, or Internet Explorer's first-launch \r\nconfiguration is not complete. Specify the UseBasicParsing parameter and try \r\nagain. \r\nAt C:\Users\cloudbase-init\AppData\Local\Temp\d4a44534-80d5-485a-b451-95833cf4f\r\n9c4.ps1:8 char:9\r\n+

I am wondering if there is a better way to pull the meta data i have added to the VM for the customization (is there a way to call directly via a customization script?) or is there a known work around ?

for reference i am using the cloudbase 2012 R2 image on a KVM backed Ubuntu Openstack

many thanks

James

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2017-01-02 04:32:31 +0300

alexpilotti gravatar image

You need to add the -UseBasicParsing parameter when calling Invoke-WebRequest from a userdata script. Reason for this is that otherwise Invoke-WebRequest will try to parse the response using IE components, not available in this context.

edit flag offensive delete link more

Comments

many thanks, that looks to have worked as expected. is this the best way to call meta-data for the builds or do you guys suggest a different mechanism, also is there a way to post meta-data back out from the VM via the local 169 service or similar ? thanks again

James laming gravatar imageJames laming ( 2017-01-02 23:07:05 +0300 )edit

Your Answer

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

Add Answer

[hide preview]

Question Tools

Stats

Asked: 2017-01-02 00:44:19 +0300

Seen: 65 times

Last updated: Jan 02