add documentation for creating/deleting files

This commit is contained in:
2023-11-15 07:14:05 +01:00
parent e690e64103
commit 142c0a9c52

View File

@@ -2,52 +2,6 @@
With Hiera it is possible to download files and git repositories as well as to create directories and symlinks.
## Download Files
Files to download need to be placed on a git repository on `git.psi.ch` (internal) or `gitlab.psi.ch` (DMZ, Extranet, Tier3), where they need to be publicly available.
For configuration in Hiera there is the `filecopy::files` hash where the keys is the destination path of the file. And the value is another hash with following options:
- `repo`: the Git repository to download from
- `branch`: the Git branch in the repository (optional, default `master`)
- `path`: the file path inside the repository
- `owner`: file owner (optional, default `root`)
- `mode`: file permissions (optional, default `0644`)
Example:
```
filecopy::files:
'/tmp/test1':
repo: 'talamo_i/copy-file-test'
path: 'abc'
mode: '0600'
owner: 'talamo_i'
```
Note that the `filecopy::files` hash is **not merged** over the hierarchy, so only the most specific one will apply.
This download functionality can be disabled with
```
base::enable_filecopy: false
```
## Download Git Repositories
To synchronize a git repository to the host you might list them in the `files::git` hash. The key is the destination directory and the value is a hash with following options:
- `url`: URL of the public git repository to clone
- `revision`: what branch, tag or commit-hash should be checked out
Example:
```
files::git:
/var/test/container-images:
url: 'https://git.psi.ch/linux-infra/container_images.git'
revision: 'main'
```
## Create Directories
@@ -94,3 +48,75 @@ Then also existing files and symlinks are not overwritten. Also this can be chan
files::symlinks::force: true
```
but this is then applies for all symlink definitions.
## Create (Text) Files with Specific Content
Textfiles with specific content can be created as follows:
```yaml
files::files:
/testdir/test/three:
content: |
hello world t
this is a test
```
## Delete Files / Directories
Individual files and directories can be deleted as follows:
```yaml
files::files:
/testdir/test/two:
ensure: absent
force: true
```
The option `force: true` is only needed for directories. For a directory, if absent, the directory will not be deleted (even if it is empty)!
## Download Git Repositories
To synchronize a git repository to the host you might list them in the `files::git` hash. The key is the destination directory and the value is a hash with following options:
- `url`: URL of the public git repository to clone
- `revision`: what branch, tag or commit-hash should be checked out
Example:
```
files::git:
/var/test/container-images:
url: 'https://git.psi.ch/linux-infra/container_images.git'
revision: 'main'
```
## Download Files
Files to download need to be placed on a git repository on `git.psi.ch` (internal) or `gitlab.psi.ch` (DMZ, Extranet, Tier3), where they need to be publicly available.
For configuration in Hiera there is the `filecopy::files` hash where the keys is the destination path of the file. And the value is another hash with following options:
- `repo`: the Git repository to download from
- `branch`: the Git branch in the repository (optional, default `master`)
- `path`: the file path inside the repository
- `owner`: file owner (optional, default `root`)
- `mode`: file permissions (optional, default `0644`)
Example:
```
filecopy::files:
'/tmp/test1':
repo: 'talamo_i/copy-file-test'
path: 'abc'
mode: '0600'
owner: 'talamo_i'
```
Note that the `filecopy::files` hash is **not merged** over the hierarchy, so only the most specific one will apply.
This download functionality can be disabled with
```
base::enable_filecopy: false
```