New Question
0

userdata and powershell script on cloudbase-init

asked 2017-06-29 07:25:10 +0200

Nebukazar gravatar image

Hi,

We're currently developing powershell scripts to automate our windows server guest deployment but we're facing some issues and therefore, having some questions:

1) Does cloudbase-init support script URL inclusion when specifying userdata ? eg:

#include
http://someurl.com/somescript_here

2) Is there any code parsing issue ? Our code doesn't seem to be running and is causing some exception to be thrown. This is when we're giving the code directly within userdata (-vs- specifying an inclusion as mentioned above).

Please note the code is running just fine when we're executing it directly within the instance.

Please also note that userdata powershell script that only has a few lines with no special character is working fine as well eg:

#ps1
net user blabla pwd123

So here is the cloudbase-init log snippet:

2017-06-28 23:45:51.058 2640 DEBUG cloudbaseinit.plugins.common.userdatautils [-] User_data stderr:
b'At C:\\Users\\cloudbase-init\\AppData\\Local\\Temp\\9d2a38d8-48fe-41fb-b8c1-b09007fadad1.ps1:72 char:31\r\n+ ... abet=$NULL;For ($a=65;$a \x83?"le 90;$a++) {$alphabet+=,[char][byte]$a }\r\n+                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\nUnexpected token \'\x83?"le 90;$a++) {$alphabet+=,[char][byte]$a }\r\n$ascii=$NULL;For ($a=33;$a \x83?"le\' in expression or statement.\r\nAt C:\\Users\\cloudbase-init\\AppData\\Local\\Temp\\9d2a38d8-48fe-41fb-b8c1-b09007fadad1.ps1:73 char:37\r\n+ $ascii=$NULL;For ($a=33;$a \x83?"le 126;$a++) {$ascii+=,[char][byte]$a }\r\n+                                     ~\r\nMissing closing \')\' after expression in \'for\' statement.\r\nAt C:\\Users\\cloudbase-init\\AppData\\Local\\Temp\\9d2a38d8-48fe-41fb-b8c1-b09007fadad1.ps1:73 char:42\r\n+ $ascii=$NULL;For ($a=33;$a \x83?"le 126;$a++) {$ascii+=,[char][byte]$a }\r\n+                                          ~\r\nUnexpected token \')\' in expression or statement.\r\nAt C:\\Users\\cloudbase-init\\AppData\\Local\\Temp\\9d2a38d8-48fe-41fb-b8c1-b09007fadad1.ps1:76 char:21\r\n+ For ($loop=1; $loop \x83?"le 9; $loop++) {\r\n+                     ~~~~~~~~~~~~~~~~~~~\r\nUnexpected token \'\x83?"le 9; $loop++) {\r\n\t$Username+=($alphabet | GET-RANDOM)\r\n}\r\necho "Username:\' in expression or statement.\r\nAt C:\\Users\\cloudbase-init\\AppData\\Local\\Temp\\9d2a38d8-48fe-41fb-b8c1-b09007fadad1.ps1:83 char:28\r\n+ For ($loop=1; $loop \x83?"le 9; $loop++) {\r\n+                            ~\r\nMissing closing \')\' after expression in \'for\' statement.\r\nAt C:\\Users\\cloudbase-init\\AppData\\Local\\Temp\\9d2a38d8-48fe-41fb-b8c1-b09007fadad1.ps1:83 char:37\r\n+ For ($loop=1; $loop \x83?"le 9; $loop++) {\r\n+                                     ~\r\nUnexpected token \')\' in expression or statement.\r\n    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException\r\n    + FullyQualifiedErrorId : UnexpectedToken\r\n \r\n' execute_user_data_script c:\program files\cloudbase solutions\cloudbase-init\python\lib\site-packages\cloudbaseinit\plugins\common\userdatautils.py:94

3) Our windows guests are getting 2 interfaces. The first one is being configured as static ip address while the second one is using DHCP - it is basically matching our neutron subnet configurations. Due to some limitation, we cannot use DHCP on the primary interface / neutron subnet. Is there a way to speed up the static IP configuration process ? DHCP configuration happens within seconds while static network IP configuration takes minutes.

If that is not possible, is there a ... (more)

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2017-06-29 12:57:30 +0200

avladu gravatar image

updated 2017-06-29 13:04:48 +0200

Hello,

For question 1: You might want to check the multipart userdata, where you can put multiple files on the disk using cloud-config writefiles (in gzip+base64 for example) or run multiple scripts. Here is a comprehensive example on what you can do: https://github.com/cloudbase/cloudbase-init-ci/blob/master/argus/resources/windows/multipartuserdata .

For question 2: Make sure your script does not have characters copied over from other sources like the dash - versus the long dash (em dash) https://www.utf8icons.com/character/8... .

For question 3: Can you give more details on what your http://169.254.169.254/openstack/late... looks like? We are currently working on a patch to support the neutron provided network config from the metadata. This way, cloudbase-init can set the static network configuration.

Thank you, Adrian Vladu

edit flag offensive delete link more

Comments

Thanks for your answers. #1 = I'll take a look and let you know if I encounter any issues. [...]

Nebukazar gravatar imageNebukazar ( 2017-06-29 21:49:22 +0200 )edit

#2 = The code appears to be working just fine locally; I don't think there is "special" character in the code as this wouldn't be able to execute locally. I'm doing some more testing by encoding the file and using some other alternatives. I'll keep you posted. [...]

Nebukazar gravatar imageNebukazar ( 2017-06-29 21:50:22 +0200 )edit

So basically, only #3 is pending at the moment. Thanks ! :)

Nebukazar gravatar imageNebukazar ( 2017-06-29 21:51:13 +0200 )edit

#3 = The guest is unable to reach that address (subnet is not using dhcp), I'm still seeing the following in the guest's cloud-init logfile: http://paste.openstack.org/show/614111/ and content of the ConfigDrive's network_data.json : http://paste.openstack.org/show/614112/ [...]

Nebukazar gravatar imageNebukazar ( 2017-06-29 21:52:12 +0200 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-06-29 07:25:10 +0200

Seen: 14,623 times

Last updated: Jun 29 '17