Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCIBox deployment fails if passwords contain dollar signs #1590

Closed
marcelloformica opened this issue Jan 9, 2023 · 2 comments · Fixed by #1602 or #1649
Closed

HCIBox deployment fails if passwords contain dollar signs #1590

marcelloformica opened this issue Jan 9, 2023 · 2 comments · Fixed by #1602 or #1649
Assignees
Labels
bug Something isn't working HCIBox Jumpstart HCIBox related

Comments

@marcelloformica
Copy link
Member

Is your issue related to a Jumpstart scenario, ArcBox, or HCIBox?
HCIBox

Describe the bug
If the windowsAdminPassword string in the main.parameters.json file contains dollar signs ($), the HCIBox deployment fails during the autorun script execution, because of the following error:
Import-PowerShellDataFile : The file 'C:\HCIBox\HCIBox-Config.psd1' could not be parsed as a PowerShell Data File.

The issue seems to be caused by the $ signs that are not correctly handled inside the HCIBox-Config.psd1.
In details: the password specified in main.parameters.json is automatically written into the following line in HCIBox-Config.psd1:

SDNAdminPassword = "%staging-password%" # Do not change - this value is replaced during Bootstrap with the password supplied in the ARM deployment

but, if the password string contains dollar signs, Import-PowerShellDataFile cannot parse that updated file anymore, probably because $ are special characters, unless the string is enclosed in single quotes.
I was actually able to load the file after changing the double quote in the above line with a single quote - this maybe can fix the problem.

To Reproduce

  1. In the preparation steps, edit the main.parameters.json file as described in the documentation. In "windowsAdminPassword", specify a password string containing two dollar signs $$
  2. launch the Bicep deployment, that works correctly
  3. login to the HCIBox-Client machine with the specified password; this works
  4. the autorun script starts, immediately showing an error while loading the C:\HCIBox\HCIBox-Config.psd1
  5. the script is still able to download the VHDs, but the after unzipping the Ubuntu image, it fails in Register-AzSHCI.ps1:25 with the following error in the log:
    TerminatingError(ConvertTo-SecureString): "Cannot bind argument to parameter 'String' because it is null."
    The null string is the SDNAdminPassword that was not set because HCIBox-Config.psd1 was not correctly parsed in the previous steps.

Expected behavior
The script should work even if the password contains one or more dollar signs.

Environment summary
azure-cli 2.43.0

@marcelloformica marcelloformica added bug Something isn't working triage issue or feature up for triage labels Jan 9, 2023
@github-actions
Copy link

github-actions bot commented Jan 9, 2023

Hey friend! Thanks for opening this issue. We appreciate your contribution and welcome you to our community! We are glad to have you here and to have your input on the Azure Arc Jumpstart.

@dkirby-ms dkirby-ms self-assigned this Jan 9, 2023
@dkirby-ms dkirby-ms added the HCIBox Jumpstart HCIBox related label Jan 9, 2023
@dkirby-ms
Copy link
Contributor

Good catch and summary of your fix. I will investigate making the switch to single quotes permanent for this field and others where we are doing string replacements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working HCIBox Jumpstart HCIBox related
Projects
None yet
3 participants