Configuration > Resources
file
Description
This resource manages a file within the fileystem hierarchy of the client. Its main parameter is path
.
Relationship to other resources
The value of the path
parameter must be unique among all file, directory and symlink resources.
A file implicitly depends on directory or symlink resources whose path
parameters are ancestors to the file path
. For example when the path
parameter of this file is set to /my/elaborate/file/path
and there is a directory resource whose path
is /my/elaborate
, then the former implicitly depends on the latter.
Parameters
To declare a resource within the [[resources]]
array as a file, set the type
meta-parameter to file
.
In addition to the meta-parameters listed in Resources, this table lists all resource-specific parameters:
Name | TOML type | Description | Mandatory | Default |
---|---|---|---|---|
ensure |
string |
Determines the desired state of the resource. One of:
| yes | present |
path |
string | Primary parameter. An absolute filesystem path. | yes | |
mode |
string | The file permission mode in octal notation. | yes | 644 |
owner |
string | The name of the user who owns this file. | yes | root |
group |
string | The name of the group who owns this file. | no | |
Only one of the following two parameters can be present at a time. | ||||
content |
string | A string to be written as-is to the file. | no | |
source |
string |
An absolute path to a file asset stored on the server. The remote file content will be downloaded from pullconfd and copied to the file at
If this parameter contains the path |
no |
Examples
Empty file
[[resources]]
type = "file"
path = "/my/elaborate/file/path"
Download from pullconfd
[[resources]]
type = "file"
ensure = "present"
path = "/my/elaborate/file/path"
owner = "myuser"
group = "mygroup"
# Downloads the file from https://<pullconfd>/assets/file/path/on/the/server, i.e. $PULLCONF_ASSET_DIR/file/path/on/the/server
source = "/file/path/on/the/server"
Declare file contents statically
[[resources]]
type = "file"
ensure = "present"
path = "/my/elaborate/file/path"
owner = "myuser"
group = "mygroup"
content = """
my
multiline
example file content
"""