allow Exec to be a String or Array of Strings - #106
Closed
jcpunk wants to merge 1 commit into
Closed
Conversation
When Exec is an Array, elements are joined with a single space before being written to the quadlet file, producing the same output as the equivalent single-string form. This allows long argument lists to be expressed cleanly in Hiera as arrays rather than one long string.
traylenator
reviewed
Apr 22, 2026
| super().merge( | ||
| container_entry: { | ||
| 'Image' => 'prom/node-exporter:latest', | ||
| 'Exec' => [ |
Collaborator
There was a problem hiding this comment.
I'm not sure about this one.
Having Exec do something magic and concatenating values here seems counter intuitive. I would expect an array of Exec to create multiple Exec lines in the quadlet.
That may make no sense but .
In yaml you have two options:
Exec: |
'--path.procfs=/host/proc' \
'--path.sysfs=/host/sys' \
'--path.rootfs=/host' \
'--web.listen-address=[::]:9100'or the slightly less obvious but magic
Exec: >
'--path.procfs=/host/proc'
'--path.sysfs=/host/sys'
'--path.rootfs=/host'
'--web.listen-address=[::]:9100'I've never tried the latter one in puppet context but should work.
In fact I only just learnt it from the Block Scalers section of https://yaml-multiline.info/
Contributor
Author
There was a problem hiding this comment.
I was unaware of Block Scalers. That is better than this magic.
Contributor
Author
|
For folks coming in late, I'm using this in production without issue: Exec: >-
--path.procfs=/host/proc
--path.sysfs=/host/sys
--path.rootfs=/host
--path.udev.data=/host/run/udev/data
--web.listen-address=[::]:9100
--collector.textfile.directory=/host/%{lookup('prometheus_node_exporter_textfile_directory')}
--collector.filesystem.mount-points-exclude=^/(dev|proc|sys|var/lib/docker/.+|var/lib/kubelet/.+)($|/)
--collector.filesystem.fs-types-exclude=^(cvmfs2|shm|autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs|erofs)$
--collector.netclass.ignored-devices=^(lxc[a-f0-9]{12}|cni[a-f0-9]+|tunl\d+|vxlan\..+|veth[a-f0-9]{8})$
--collector.netdev.device-exclude=netdev_exclude
--collector.cgroups
--collector.cpu.info
--collector.hwmon
--collector.processes
--collector.systemd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request (PR) description
For massive exec lines, it is easier to have them as an array in hiera so I can parse them.
This Pull Request (PR) fixes the following issues