Files and Directories

  • file.copy
  • file.download
  • file.link
  • file.remove
  • directory.copy

Note

The following commands expect the from/source to point to files/directories which are themselves under a "files" directory. This is a restriction so that comtrya knows not to parse any .yaml file e.g. a config for a different tool as a manifest. To see how it works check the examples

  • file.link
  • file.copy
  • directory.copy

file.copy

Action used to copy a file from one location to another.

KeyTypeOptionalDescription
actionstringnofile.copy
fromstringnosource file
tostringnodestination file
templatebooleanyesrenders files using context providers
default: false
chmodintegeryesoctal permissions

Examples

# Simple file copy
- action: file.copy
  from: procs-config.toml
  to: "{{ user.config_dir }}/procs/config.toml"

# With template and permissions
- action: file.copy
  from: managed_file
  to: /root/file
  template: true
  chmod: 644
  
# With encrypted file
- action: file.copy
  from: encrypted-file
  to: /tmp/some-decrypted-file
  passphrase: "1KZ2EXDHSQKZFQP43JK2LPXUFZ8D365CM5WQXRSH97U7N9WKRVFKS0TCS30"

file.download

This action will download a file.

KeyTypeOptionalDescription
actionstringnofile.download
fromstringnosource location
tostringnodestination file

An alias also exists such that source can be used in lieu of from and target can be used in lieu of to.

Example

actions:
  # This will be rendered with contexts
  - action: file.download
    from: https://google.com/robots.txt
    to: /tmp/google-robots.txt

Create a symlink for files. This action can be used to symlink a single file or files in a directory.

KeyTypeOptionalDescription
actionstringnofile.link
fromstringnosymlink location
tostringnosymlink points to
walk dirbooleanyesWalk diles in directory
default: false
sourcestringyesUsed in conjunction with walk dir
in liue of from

Example

# Symlink for a single file
- action: file.link
  from: /root/symlink
  to: managed_file
  
# Symlink for all files in a directory
- action: file.link
  source: walker
  target: /tml/walker-123
  walk_dir: true

file.remove

Removes a file.

KeyTypeOptionalDescription
actionstringnofile.remove
targetstringnofile to be removed

Example

- action: file.remove
  target: /tmp/some-file-rendered

directory.copy

Copies a directory on the filesystem to another location.

KeyTypeOptionalDescription
actionstringnodirectory.copy
fromstringnosource directory
tostringnodestination directory

Example

- action: directory.copy
  from: managed_directory
  to: /root/location