Advanced File Operations¶
This example demonstrates Mooncake's expanded file management capabilities:
File States¶
state: file - Create or update files¶
state: directory - Create directories¶
state: absent - Remove files or directories¶
Remove non-empty directory:
state: touch - Create empty file or update timestamp¶
state: link - Create symbolic links¶
state: hardlink - Create hard links¶
state: perms - Change permissions without creating¶
Copy Action¶
Copy files with checksum verification:
- copy:
src: ./app-v1.2.3
dest: /usr/local/bin/app
mode: "0755"
checksum: "sha256:abc123..."
backup: true
Ownership Management¶
Set file owner and group:
Running the Example¶
# Dry-run to see what would happen
mooncake run config.yml --dry-run
# Execute the configuration
mooncake run config.yml
# View the created structure
tree /tmp/mooncake-demo
Features Demonstrated¶
- ✅ Creating directory structures with loops
- ✅ Creating files with inline content
- ✅ Touch files (timestamp updates)
- ✅ Symbolic and hard links
- ✅ Permission-only changes
- ✅ File copying with backup
- ✅ Conditional file removal
- ✅ Force removal of non-empty directories
- ✅ Ownership management with become