GuidesModules
file.absent
Ensures a file or directory does not exist at the specified path.
Source: pkg/state/modules/file_absent.go
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | No | State ID | Absolute path to the file or directory to remove. If omitted, the state ID is used as the path. |
All states also accept the full set of requisite parameters and Salt-parity state attributes — see Dependencies & Requisites.
Check Behavior
- Path existence — stats the path.
- If the path does not exist (stat returns an error), the state reports no changes needed.
- If the path exists (file or directory), the state needs changes.
Apply Behavior
- Removes the file or directory (and all contents if a directory) via
RemoveAll.
Revert Behavior
No-op. File or directory removal cannot be reverted because the original content is not preserved.
Examples
Direct Execution
# Remove a file
zester 'web-01' file.absent /tmp/old-config.txt
# Remove a directory from all peels
zester '*' file.absent /opt/deprecated-appState File
Remove a configuration file:
/etc/nginx/sites-enabled/default:
file.absent: []Clean up after decommissioning:
remove_old_app:
file.absent:
- name: /opt/old-app
- require:
- "cmd.run:stop_old_app"Remove multiple obsolete files:
/tmp/deploy-key:
file.absent: []
/var/log/old-app.log:
file.absent: []