zester
GuidesModules

file.absent

Ensures a file or directory does not exist at the specified path.

Source: pkg/state/modules/file_absent.go


Parameters

ParameterTypeRequiredDefaultDescription
namestringNoState IDAbsolute 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

  1. Path existence — stats the path.
  2. If the path does not exist (stat returns an error), the state reports no changes needed.
  3. If the path exists (file or directory), the state needs changes.

Apply Behavior

  1. 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-app

State 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: []

On this page