add additional example, add syntax highlighting

This commit is contained in:
ebner committed 2025-05-15 11:32:46 +02:00
1 parent 5982a3a12b
commit 787a12fe8b
1 file changed
+25 -13
@@ -15,7 +15,7 @@ Parent directories are automatically created with default settings. If that is n
Example:
```
```yaml
files::directories:
/etc/test1:
/etc/test2/foo/bar:
@@ -31,20 +31,20 @@ pathnames of the symlinks, the values of the hash are the corresponding symlink
targets.
Example:
```
```yaml
files::symlinks:
'/opt/foo': '/var/lib/foo'
```
Per default the symlink definitions are not merged over the full Hiera hierarchy, only the most specific definiton is used. To allow merge, set
```
```yaml
files::symlinks::merge: true
```
Then also existing files and symlinks are not overwritten. Also this can be changed with
```
```yaml
files::symlinks::force: true
```
but this is then applies for all symlink definitions.
@@ -88,7 +88,7 @@ To synchronize a git repository to the host you might list them in the `files::g
Example:
```
```yaml
files::git:
/var/test/container-images:
ensure: latest
@@ -101,13 +101,14 @@ Note that submodules are automatically initialized, if you wish different set `s
If you need to use a token to access the repository ([how to get a token](https://linux.psi.ch/services/gitea/gitea-faq.html#i-need-a-service-user-token-for-automation)), you can
- include it into the URL (which makes to token visible inside the checkout as it is part of the `remote` configuration)
- rewrite the URL in `~/.gitconfig` of `user` (which then will cover all `git` operations with the respective URL prefix):
```
```yaml
[url "https://a84t...4ksf@gitea.psi.ch/"]
insteadOf = https://gitea.psi.ch/
```
[]()
See the chapter "Encrypt Part of File Content/Download URL in Hiera" more below how to best deal with encrypting the token, or below full example:
```
```yaml
gitea::token::lx-gitea: 'ENC[PKCS7,MIIBmQYJKoZI...dvkM=]'
files::git:
@@ -120,7 +121,7 @@ files::git:
ensure: latest
branch: preprod
/home/lx-test/puppet:
url: 'https://%{lookup('gitea::token::lx-gitea')}@gitea.psi.ch/puppet/puppet.git'
url: "https://%{lookup('gitea::token::lx-gitea')}@gitea.psi.ch/puppet/puppet.git"
user: lx-test
files::files:
@@ -141,7 +142,7 @@ Note that once downloaded files are kept on the Puppet server. On each Puppet ru
"Simple" downloads can go with the hash `files::download` where you can map destination file pathes to URLs or with more detailed configuration including token and destination file permissions:
```
```yaml
files::download:
'/tmp/dummy.pdf': 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'
'/tmp/dummy.png':
@@ -151,7 +152,18 @@ files::download:
mode: '0444'
```
If a token is needed to access the webserver, you may provide it with the `token` parameter ([how to get a token](https://linux.psi.ch/services/gitea/gitea-faq.html#i-need-a-service-user-token-for-automation)).
#### Download Token
If a token is needed to access the web or git server, you may provide it with the `token` parameter.
```yaml
files::download:
'/tmp/dummy.png':
url: 'https://www.filesampleshub.com/download/image/png/sample1.png'
token: 'token: 'ENC[PKCS7......]'
```
If you need a token for gitea.psi.ch see [how to get a token](https://linux.psi.ch/services/gitea/gitea-faq.html#i-need-a-service-user-token-for-automation).
### Download Lists
@@ -159,7 +171,7 @@ For more complex configurations you can do "file download lists" which can be pr
The list configuration allows to set the default values and an `url-prefix` which is then used for all downloaded files if not specified in more detail for the individual files:
```
```yaml
files::download_list::test:
url-prefix: 'https://gitea.psi.ch/linux/documentation/raw/branch/master/'
token: ENC[PKCS7,MIIBmQ...Lg=]
@@ -196,7 +208,7 @@ For configuration in Hiera there is the `filecopy::files` hash where the keys is
Example:
```
```yaml
filecopy::files:
'/tmp/test1':
repo: 'talamo_i/copy-file-test'
@@ -216,7 +228,7 @@ base::enable_filecopy: false
If you want to provide a secret like a password or a token inside the file content or as part of an URL, store the [eyaml encrypted encrypt secret](../../puppet/hiera) in an else unused Hiera key and include it into the actual place using string interpolation and the `lookup` function:
```
```yaml
my-project::my-user::my-password: 'ENC[PKCS7,MIIBmQYJKoZI...dvkM=]'
files::files: