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

Conditional values for SearchCriteria and Filters #128

Open
raptorrico opened this issue Apr 28, 2023 · 1 comment
Open

Conditional values for SearchCriteria and Filters #128

raptorrico opened this issue Apr 28, 2023 · 1 comment

Comments

@raptorrico
Copy link

I need to conditionally define the parameter values for SearchCriteria and Filters. Would I need to run the windows-update.ps1 script rather than using the provisioner?

For example, set variables for both and then call the script

$varSearchCriteria = 'IsInstalled=0'
$varFilters = @('include:$true')

windows-update.ps1 -SearchCriteria $varCriteria -Filters $varFilters

Is it possible to achieve the above using the provisioner?

@saily
Copy link

saily commented Aug 15, 2024

Hi @raptorrico, not sure this helps with your use-case, but I override the value of my variable update (which is true by default) using packer build -var update=false ... to skip updates for faster testing, see below:

provisioner "windows-update" {
    search_criteria = "IsInstalled=0"
    filters = var.update ? ["exclude:$true"] : [
      "exclude:$_.Title -like '*Preview*'",
      "exclude:$_.Title -like '*Silverlight*'",
      "exclude:$_.InstallationBehavior.CanRequestUserInput",
      "include:$true"
    ]
}
´´´

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

No branches or pull requests

2 participants