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

Switching credential during provisioning for Windows servers #9664

Open
wilber82 opened this issue Jul 29, 2020 · 3 comments
Open

Switching credential during provisioning for Windows servers #9664

wilber82 opened this issue Jul 29, 2020 · 3 comments
Labels

Comments

@wilber82
Copy link

My image configuration process has 3 steps:

  1. Basic configure OS via PowerShell script by local 'Administrator' account. (For example, set timezone)
  2. Join the VM to domain by PowerShell script.
  3. Install a software via PowerShell script by domain account.
  4. Leave domain via PowerShell script.
  5. Continue configure OS via PowerShell by local 'Administrator' account.

As you can see. It needs domain account to connect the server.
Looks like there is no way to switching credential temporarily during provisioning.

I tried to give "elevated_user" and "elevated_password" in PowerShell block. No lucky.

Even I don't give any additional keys, the audit log shows Packer tries to login the machine by '[email protected]" but not local 'administrator' account. It always failed as I'm not domain administrator.

Is this a bug, or?

My builders block is correct. I'm using winrm as communicator. it works fine for any VM without the need to switch account.

@SwampDragons
Copy link
Contributor

You're right. Currently there is no way to change the communicator credentials halfway through a build.

@allaboutopensource
Copy link

you can create a powershell script and inside the script you can mention the new admin credentials so that those commands in the scripts will run using the admin credentials and not the local admin. hope this helps.

@techtryhard11
Copy link

@allaboutopensource @SwampDragons Do you know of a way to run a powershell script with packer during the build process? I have only seen the use of custom_script and standard ssh/winrm communicators. I am having some trouble getting the custom_script to execute as suggested here: https://developer.hashicorp.com/packer/integrations/hashicorp/azure/latest/components/builder/arm under custom_script. Do you have any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants