Built-in module reference
on this page
Modules:
registry,
service,
file,
directory,
package,
winget_package,
choco_package,
scoop_package,
remove_appx_packages,
shortcut,
scheduled_task,
user,
power_plan,
windows_feature,
environment,
firewall_rule,
powershell,
shell,
reboot,
wait.
Execution contract
Each module implements Check() and Apply(). Preflight calls Check() first:
- No change needed: the task reports
okandApply()does not run. - Change needed:
Apply()runs and the task reportschanged. Underpreflight check,Apply()does not run and the task reportschangedwith the messagewould apply change (dry-run).
Task forms
Inline:
- name: Create content directory
directory:
path: "C:\\Exhibits\\Content"Explicit:
- name: Create content directory
module: directory
params:
path: "C:\\Exhibits\\Content"Inline parameters are validated against the module schema before the run, and unknown parameters are errors. params in the explicit form is not schema-validated.
Platform and transport support
Every built-in module runs on local, ssh, and winrm targets. Every target must be Windows with Windows PowerShell. The local target requires a Windows controller.
Some operations cannot complete over WinRM; see WinRM session limitations.
Plugin modules run on every transport; see Execution model.
An unknown module name fails at plan time; see Plan-time checks.
WinRM session limitations
WinRM authenticates with Basic auth, so only local accounts work, and each operation runs under a non-interactive network logon. These operations fail in that session:
| Operation | Failure |
|---|---|
windows_feature enable or disable | The symbolic link cannot be followed because its type is disabled. DISM cannot follow component store links under a network logon. Reading feature state works. |
remove_appx_packages with all_users or both scope | Remove-AppxPackage -AllUsers fails with HRESULT 0x80073D19, An error occurred because a user was logged off. |
| Output streaming | Output arrives in one batch when the command ends, not line by line. |
WinRM has no CredSSP option; see Would CredSSP help?. Workarounds:
- Run on the machine with the
localtarget or a staged bundle. - Run from an interactive or elevated context, such as a scheduled task.
- For streaming output, use SSH.
Modules
registry
Manages a registry key and its values.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
path | string | yes | Key path. Accepts HKLM, HKCU, HKCR, HKU, and HKCC prefixes, with or without :, and the HKEY_* names | |
values | list | no | Value specs | |
ensure | present, absent | no | present | absent deletes the key and its subkeys |
user | string | no | Local user whose HKCU hive to edit; requires an HKCU path |
Registry value spec
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | yes | Value name | |
type | string, expand_string, dword, qword, binary, multi_string | no | inferred from data | Value type |
data | any | with ensure: present and no patch | Value data | |
patch | list | no | Byte patches for an existing binary value; each entry has offset (integer) and data (byte, 0-255). Cannot be combined with data | |
ensure | present, absent | no | present | Desired value state |
Without type, a string is string, an integer or boolean is dword, a list of strings is multi_string, and a list of numbers is binary.
With user, the user’s profile hive is loaded for the task and unloaded after it. Errors:
user <name> was not found on this machineuser <name> has no profile on this machine; sign in once to create itregistry: user can only be used with HKCU/HKEY_CURRENT_USER paths
- name: Enable taskbar auto-hide
registry:
path: 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3'
values:
- name: Settings
type: binary
patch:
- offset: 8
data: 3service
Manages an existing Windows service.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | yes | Service name | |
state | running, stopped, disabled | no | disabled stops the service and sets startup to disabled, and ignores startup_type | |
startup_type | automatic, manual, disabled | no | Startup type |
Fails with service not found: <name> when the service does not exist.
- name: Start Windows Time
service:
name: W32Time
state: running
startup_type: automaticfile
Manages a file on the target.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
dest | string | yes | Path on the target | |
src | string | no | Path on the controller to copy | |
content | string | no | File content; accepts secret:<name> | |
content_template | string | no | File content rendered as a template; accepts secret("name") | |
ensure | present, absent | no | present | Desired state |
- Set at most one of
src,content, andcontent_template. Check()compares SHA-256 hashes of the source and the target file.contentandcontent_templateare written as UTF-8 without a byte order mark. Parent directories are created.- With none of the three set, a missing file is created empty and an existing file is left unchanged.
content_templaterenders after all other parameters; see Secrets in templates.
- name: Write app config
file:
dest: "C:\\Exhibits\\app.ini"
content_template: |
username={{ vars.app_user }}
password={{ secret("app-password") }}directory
Manages a directory.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
path | string | yes | Directory path | |
ensure | present, absent | no | present | present creates parent directories; absent deletes the directory and its contents |
- name: Create content directory
directory:
path: "C:\\Exhibits\\Content"package
Installs or removes MSI and EXE packages.
| Parameter | Type | Required | Description |
|---|---|---|---|
packages | list | yes | Package entries |
Each entry:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
product_id | string | yes | Product code, matched against the uninstall registry keys | |
source | string | with ensure: present | Installer path on the controller; copied to a temporary directory on the target before install | |
args | string[] | no | Extra installer arguments | |
ensure | present, absent | no | present | Desired state |
- An
.msisource runsmsiexec /i <source> /qn /norestart <args>. Any other source runs directly withargs. absentrunsmsiexec /x <product_id> /qn /norestart.- A non-zero exit code fails the task.
- name: Install packages
package:
packages:
- product_id: "{D5E71B88-9A6C-4B6B-89C0-123456789ABC}"
source: "C:\\Installers\\app.msi"
- product_id: "{0F1E2D3C-4B5A-6978-8796-A5B4C3D2E1F0}"
ensure: absentwinget_package
Installs or removes packages with winget.
| Parameter | Type | Required | Description |
|---|---|---|---|
packages | list | yes | Package entries |
Each entry:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
id | string | yes | winget package ID, matched exactly | |
version | string | no | Exact version to install | |
source | string | no | winget source name | |
args | string[] | no | Extra winget arguments for this package | |
scope | machine, user | no | machine | Install scope |
ensure | present, absent | no | present | Desired state |
- Without
version, an installed package satisfiespresent. Withversion, the installed version must match. - Each
idmay appear once, compared case-insensitively. WinGet can’t install two versions of one package side by side. - Installs run
winget install --id <id> --exact --silent --scope <scope>with agreements accepted. Removals runwinget uninstall --id <id> --exact. - After making changes, the task reads installed packages again and fails if any changed entry still isn’t in its desired state. WinGet sometimes reports a successful uninstall of a portable package that it didn’t remove.
wingetruns as the transport account. Ifwinget.exeor thewingetsource isn’t registered for that account, the task fails and asks for apreflight/wingettask first. This happens on editions without WinGet, such as Windows IoT Enterprise LTSC, and for accounts that have never signed in interactively.
- name: Install tools
winget_package:
packages:
- id: Microsoft.VisualStudioCode
version: "1.85.0"
- id: Microsoft.VisualStudio.2022.Community
args: ["--override", "--quiet --wait --norestart"]
- id: OldApp
ensure: absentchoco_package
Installs or removes packages with Chocolatey.
| Parameter | Type | Required | Description |
|---|---|---|---|
packages | list | yes | Package entries |
Each entry:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
id | string | yes | Chocolatey package ID, matched case-insensitively | |
version | string | no | Exact version to install | |
source | string | no | Source name or URL to install from | |
params | string | no | Package parameters, passed as --params | |
args | string[] | no | Extra choco arguments for this package | |
ensure | present, absent | no | present | Desired state |
- Without
version, an installed package satisfiespresent. Withversion, the installed version must match. Versions compare after dropping trailing zero parts, so1.6matches1.6.0. - Each
idmay appear once. Chocolatey keeps one version of each package. - Installs run
choco install <id> -y --no-progress. Withversion, the task runschoco upgrade <id> --version <version> --allow-downgrade -y --no-progressinstead, which installs, upgrades, or downgrades. Removals runchoco uninstall <id> -y --no-progress.source,params, andargsapply to installs and upgrades;argsalso applies to removals. - Exit codes 0, 1605, 1614, 1641, and 3010 succeed. For 1641 and 3010 the task prints that a reboot is required; add a
reboottask if the package needs one. - After making changes, the task reads installed packages again and fails if any changed entry still isn’t in its desired state.
- Chocolatey installs machine-wide, so there is no
scope. - The task runs
choco.exefrom the machine’sChocolateyInstalldirectory. If Chocolatey isn’t installed, the task fails and asks for apreflight/chocolateytask first. - Double quotes inside
paramsare removed before Chocolatey sees them. Quote values with single quotes, such as/Dir:'C:\Program Files\App'. - Requires Chocolatey 2.0 or later. The task fails on 1.x, and when it can’t read the Chocolatey version, because 1.x
choco listsearches the remote source instead of listing installed packages. - Known limitation: single quotes inside a
paramsvalue aren’t escaped, so a value can’t contain a literal'.
- name: Install tools
choco_package:
packages:
- id: 7zip
- id: jq
version: "1.7.1"
- id: vlc
params: "/Language:en"
- id: oldapp
ensure: absentscoop_package
Installs or removes Scoop apps for the transport account.
| Parameter | Type | Required | Description |
|---|---|---|---|
packages | list | yes | App entries |
Each entry:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
id | string | yes | App name, optionally with its bucket, such as extras/vscode. Matched case-insensitively, without the bucket | |
version | string | no | Exact version to install | |
active | bool | no | true for a versioned app listed once | Make this version current |
args | string[] | no | Extra scoop arguments for this app | |
ensure | present, absent | no | present | Desired state |
- Without
version, an installed app satisfiespresent. Withversion, that version must be installed, and if the entry is active, current. - Scoop keeps several versions of an app side by side. To keep more than one, list the app once per version and set
active: trueon exactly one entry. Older versions stay installed until they are removed withensure: absent. ensure: absentremoves every version, so it can’t be combined withversion.- Installs run
scoop install <id>orscoop install <id>@<version>, thenscoop reset <app>@<version>when the active version isn’t current. Removals runscoop uninstall <app>. - Pinned versions need the app’s bucket to be a git clone.
preflight/scoopsets that up. - Scoop exits 0 for some failures. The task fails when Scoop prints an error, and after making changes it reads installed apps again and fails if any changed entry still isn’t in its desired state.
- Apps install for the transport account only; there is no machine-wide scope. To install for another account, connect as that account.
- The task finds Scoop through the user-scope
SCOOPenvironment variable, or%USERPROFILE%\scoop. A machine-scopeSCOOPisn’t supported. - If Scoop isn’t installed for the transport account, the task fails and asks for a
preflight/scooptask first.
- name: Node toolchain
scoop_package:
packages:
- id: nodejs
version: "22.11.0"
active: true
- id: nodejs
version: "20.18.0"
- id: versions/python310remove_appx_packages
Removes AppX packages.
| Parameter | Type | Required | Description |
|---|---|---|---|
packages | list | yes | Package entries |
Each entry:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | yes | Package name; accepts * wildcards | |
scope | current_user, all_users, provisioned, both | no | both | both covers all users and provisioned packages |
ensure | absent | no | Desired state |
- Packages that Windows marks
NonRemovableare ignored. - A failed provisioned-package removal prints a warning and does not fail the task.
- name: Remove preinstalled apps
remove_appx_packages:
packages:
- name: Microsoft.Xbox*
- name: Microsoft.BingNews
scope: provisionedshortcut
Creates or updates a .lnk shortcut.
| Parameter | Type | Required | Description |
|---|---|---|---|
destination | string | yes | .lnk path |
target | string | no | Target path |
args | string | no | Arguments |
icon | string | no | Icon location |
Environment variables in destination, target, and icon are expanded on the target. Parent directories are created.
- name: Add kiosk shortcut
shortcut:
destination: "%PUBLIC%\\Desktop\\Kiosk.lnk"
target: "C:\\Exhibits\\kiosk.exe"
args: "--fullscreen"scheduled_task
Manages a scheduled task.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | yes | Task name | |
execute | string | unless ensure: absent | Executable | |
path | string | no | \ | Task folder, such as \Preflight\; created when missing |
arguments | string | no | Arguments | |
working_dir | string | no | Working directory | |
trigger | startup, onlogon, daily, once | no | startup | Trigger |
start_at | string | with trigger: once | 03:00 for daily | Start time |
delay | string | no | Trigger delay for startup and onlogon: an ISO 8601 duration (PT30S) or a Go duration (30s) | |
run_as | string | no | Run-as user. SYSTEM, LOCALSERVICE, and NETWORKSERVICE run as service accounts; other users use an interactive logon | |
run_level | least, highest | no | least | Privilege level |
enabled | bool | no | true | Enabled state |
ensure | present, absent | no | present | Desired state |
Apply() unregisters and re-registers the task.
- name: Launch kiosk at logon
scheduled_task:
path: \Preflight\
name: Kiosk
execute: "C:\\Exhibits\\kiosk.exe"
trigger: onlogon
delay: 30s
run_level: highestuser
Manages a local user.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | yes | User name | |
password | string | no | Password; accepts secret:<name> | |
groups | string[] | no | Local groups to add the user to | |
ensure | present, absent | no | present | Desired state |
- A new user without
passwordis created with no password. For an existing user, omittingpasswordleaves it unchanged. groupsadds memberships and removes none.
- name: Create exhibit user
user:
name: exhibit
password: secret:exhibit-password
groups: [Users]power_plan
Manages a named power scheme.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | yes | Scheme name | |
base | string | no | balanced | Scheme to copy when creating: balanced, high_performance, power_saver, or a GUID |
activate | bool | no | true | Activate the scheme |
settings | list | no | Setting overrides | |
ensure | present, absent | no | present | absent deletes the scheme, activating Balanced first if the scheme is active |
Each settings entry:
| Field | Type | Required | Description |
|---|---|---|---|
subgroup | string | yes | Subgroup alias or GUID |
setting | string | yes | Setting alias or GUID |
ac_value | integer | no | Value on AC power |
dc_value | integer | no | Value on battery |
- name: Never sleep
power_plan:
name: Exhibit
base: high_performance
settings:
- subgroup: SUB_SLEEP
setting: STANDBYIDLE
ac_value: 0
dc_value: 0windows_feature
Enables or disables a Windows optional feature.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | yes | Feature name | |
ensure | present, absent | no | present | Desired state |
- Changes do not restart Windows. Enabling uses
-LimitAccess, so Windows Update is not contacted. - Fails with
windows_feature not found: <name>when the feature does not exist. - Changes fail over WinRM; see WinRM session limitations.
- name: Enable Telnet client
windows_feature:
name: TelnetClientenvironment
Manages an environment variable.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | yes | Variable name | |
value | string | no | Value | |
scope | machine, user | no | machine | user without user targets the connecting account |
user | string | no | Local user whose environment to edit; requires scope: user. The profile hive is loaded for the task | |
ensure | present, absent | no | present | Desired state |
user without scope: user fails with environment: user requires scope: user.
- name: Set content root
environment:
name: EXHIBIT_CONTENT
value: "C:\\Exhibits\\Content"firewall_rule
Manages a Windows Firewall rule, matched by display name.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | yes | Rule display name | |
direction | inbound, outbound | no | inbound | Direction |
action | allow, block | no | allow | Action |
protocol | tcp, udp, any | no | tcp | Protocol |
ports | integer, string, or list | no | Local ports; a list is passed as an array. Requires protocol tcp or udp | |
ensure | present, absent | no | present | Desired state |
- name: Allow kiosk control port
firewall_rule:
name: Kiosk control
direction: inbound
action: allow
protocol: tcp
ports: 8080Defaults are enforced on existing rules too: an existing rule with protocol Any is changed to TCP unless the task sets protocol: any.
powershell
Runs a PowerShell script in a new session.
| Parameter | Type | Required | Description |
|---|---|---|---|
script | string | one of script or file | Inline script |
file | string | one of script or file | Script path on the controller; its contents run on the target |
args | string[] | no | Arguments for file |
check_script | string | no | Script that decides whether a change is needed |
creates | string | no | Path that, when it exists, means no change is needed |
working_dir | string | no | Working directory; relative creates paths resolve from it |
env | object | no | Process environment variables for the script, check_script, and creates |
- Without
check_scriptorcreates, the script runs every time. check_scripttakes precedence overcreates. It must output a boolean, wheretruemeans a change is needed, or an object withneeds_changeand an optionalmessage.
- name: Register kiosk app
powershell:
check_script: |
-not (Test-Path 'HKLM:\SOFTWARE\Kiosk')
script: |
New-Item -Path 'HKLM:\SOFTWARE\Kiosk' -Force | Out-Nullshell
Runs a command with the PowerShell call operator: & <cmd> <args>.
| Parameter | Type | Required | Description |
|---|---|---|---|
cmd | string | yes | Command or executable path |
args | string[] | no | Arguments |
creates | string | no | Path that, when it exists, means no change is needed |
working_dir | string | no | Working directory; relative creates paths resolve from it |
env | object | no | Environment variables set for the command; restored afterward |
- Without
creates, the command runs every time. - A non-zero exit code fails the task with
<cmd> exited with code <code>.
- name: Register license
shell:
cmd: "C:\\Exhibits\\license.exe"
args: ["--register"]
creates: "C:\\Exhibits\\license.dat"reboot
Schedules a restart with shutdown /r /t <timeout>.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
timeout | integer | no | 300 | Seconds before the restart |
- The task always reports a change.
- Preflight does not wait for the target to restart or reconnect. Tasks after
rebootrun while the restart is pending.
- name: Restart in one minute
reboot:
timeout: 60wait
Waits until a condition is true.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
condition | port_open, file_exists, service_running | yes | Condition | |
target | string | yes | Condition target; see below | |
timeout | string | no | 5m | Go duration, such as 30s or 1h |
condition | target | True when |
|---|---|---|
port_open | host:port | A TCP connection succeeds within 2 seconds |
file_exists | Path | The path exists |
service_running | Service name | The service status is Running |
The condition is checked every 5 seconds, and the task fails with wait: timeout after <timeout> waiting for condition "<condition>" on "<target>" when the timeout passes. A condition that is already true reports no change.
- name: Wait for the content server
wait:
condition: port_open
target: "localhost:8080"
timeout: 2m