π remote_directory
π remote_directory
Upload an entire directory from the local machine (where Itamae runs) to the target system.
β‘ Actions
| Action | Description |
|---|---|
:create |
Upload the directory (default) |
:delete |
Remove the directory |
:nothing |
Do nothing (use with notifications) |
π Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
path |
String | Resource name | Destination path on the target (auto-set from resource name) |
source |
String | required β οΈ | Source directory (relative to recipe file) |
mode |
String | β | Directory permissions |
owner |
String | β | Directory owner |
group |
String | β | Directory group |
π How It Works
- π Resolve source β Expands the
sourcepath relative to the recipe fileβs directory - π€ Upload β Uploads the entire local directory to a temp path on the target via the backend
- π§ Apply attributes β Sets
mode,owner, andgroupon the temp directory - π Compare β Runs
diff -qto check if the destination differs from the uploaded content - β»οΈ Replace β If different, removes the existing directory and moves the temp directory into place
π‘ During
show_differences, a recursive diff (diff -u -r) is shown if the destination directory already exists.
π¬ Dry-Run Behavior
The source directory is uploaded to a temp path for comparison. A recursive diff shows what would change. The actual directory is not replaced.
π Examples
Upload a configuration directory
remote_directory '/etc/app/config' do
source 'files/config'
mode '0755'
owner 'app'
group 'app'
end
Upload static assets
remote_directory '/var/www/static' do
source 'files/static'
mode '0755'
owner 'www-data'
end
Upload with notification π
remote_directory '/etc/nginx/conf.d' do
source 'files/nginx-configs'
mode '0755'
owner 'root'
notifies :reload, 'service[nginx]'
end