mirror of
https://github.com/gogrlx/docs.grlx.dev.git
synced 2026-04-02 11:18:58 -07:00
5.1 KiB
5.1 KiB
title, description
| title | description |
|---|---|
| grlx.ingredients.file | file |
The file ingredient handles all file operations on various file providers (such as local files, HTTP, etc.)
file.absent
Deletes a file or directory
Parameters
| parameter | type | required | description |
|---|---|---|---|
| name | string | yes | the name/path of the file to delete |
Example
file.absent:
name: ~/.config/sytemd/user/backup.service
file.append
Appends content to a file. Only appends the content if it doesn't exist.
Parameters
| parameter | type | required | description |
|---|---|---|---|
| name | string | required | the name/path of the file to delete |
| text | string | required | the text to append to a file |
Example
file.append:
- name: /etc/profile
- text: |
export PATH=$PATH:/usr/local/go/bin
file.cached
Validates if a file is cached in the sprout's cache. If it isn't the file will be cached.
Parameters
| parameter | type | required | description |
|---|---|---|---|
| source | string | yes | a file source (such as HTTP, file, etc.) to reference |
| hash | string | no | a valid hash of the source file |
| skip_verify | boolean | no | whether to skip hash validation, false by default |
Example
file.cached:
- source: https://go.dev/dl/go1.21.3.src.tar.gz
- hash: sha256=186f2b6f8c8b704e696821b09ab2041a5c1ee13dcbc3156a13adcf75931ee488
file.content
Copies content into a given file
Parameters
| parameter | type | required | description |
|---|---|---|---|
| name | string | yes | Represents the name of a file or directory |
| makedirs | bool | no (default: false) |
Determines whether directories should be created if they don't exist |
| skip_verify | bool | no (default: false) |
Determines whether certain verifications should be skipped |
| source | string | no (if skip_verify is false) |
Represents a source file's path or name |
| source_hash | string | conditional (if source is provided) |
Represents the hash of a source file, used for verification |
| text | string/list | no | Represents the content of a file. Can be a single string or a list of items |
| sources | list | no (but required if source_hashes is provided) |
Represents multiple source files |
| source_hashes | list | Conditionally | Represents the hashes for the multiple source files mentioned in sources |
Example
file.content:
- name: /srv/ngnix/nginx.conf
- makdirs: true
- text: |
server {
listen 8080;
root /data/up1;
location / {
}
}
file.contains
Checks if a file contains a given selection. If multiple sources are provided, all must be satisfied.
Parameters
| parameter | type | required | description |
|---|---|---|---|
| name | string | yes | the name/path of the file to check |
| text | string | no | the item to search for |
| source | string | no | a file source (such as HTTP, file, etc.) to reference |
| source_hash | string | no | a hash for a given source |
| sources | list | no | a list of sources to check against |
| source_hashes | list | no | a list of source hashes |
| skip_verify | boolean | no | whether to skip hash validation, false by default |
file.directory
Handles many directory operations. Ensures that a directory exists with the given permissions.
Parameters
| parameter | type | required | description |
|---|---|---|---|
| name | string | yes | the name/path of the directory |
| makedirs | bool | no | option to make directory if it doesn't exist, defaults to true |
| user | string | no | the user who will own the directory |
| group | string | no | the group who will own the directory |
| dir_mode | string | no | the directory mode |
| file_mode | string | no | the file mode to set |
| recurse | bool | no | whether to recurse the directories and apply permissions |
Example
file.directory:
- name: /tmp/item
- makdirs: false
- user: grlx
- group: grlx
- dir_moode: 755
- recurse: false
file.exists
Checks if a file exists.
Parameters
| parameter | type | required | description |
|---|---|---|---|
| name | string | yes | the name/path of the file |
Example
file.exists:
- name: /tmp/exists
file.missing
Checks if a file is missing.
Parameters
| parameter | type | required | description |
|---|---|---|---|
| name | string | yes | the name/path of the file |
Example
file.missing:
- name: /tmp/missing
file.symlink
Creates a symlink at name that points to target
Parameters
| parameter | type | required | description |
|---|---|---|---|
| name | string | yes | the name/path of the file |
| target | string | yes | the target path to link to |
Example
file.symlink:
- name: ~/localbash
- target: /usr/bin/bash