Directory Resource
Synopsis
Manages directories on the local filesystem. Supports creating directories, copying directory contents from a source, and removing directories. Works on Windows, Linux, and macOS.
Type
Capabilities
- Get
- Set
- Test
- Delete
Properties
path
Path to the directory.
sourcePath
Source directory to copy contents from.
_exist
Whether the directory should exist.
_inDesiredState
Whether the directory is in the desired state.
Examples
Example 1 — Get a directory
Example 2 — Create a directory
Example 3 — Copy directory contents from source
Example 4 — Delete a directory
Example 5 — Configuration document
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Application log directory
type: OpenDsc.FileSystem/Directory
properties:
path: /var/log/myapp
- name: Application configuration
type: OpenDsc.FileSystem/Directory
properties:
path: /opt/myapp/config
sourcePath: /opt/myapp/config-template
Exit codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Error |
| 2 | Invalid JSON |
| 3 | Access denied |
| 4 | Invalid argument |
| 5 | IO error |
| 6 | Access denied |