Skip to content

allow Exec to be a String or Array of Strings - #106

Closed
jcpunk wants to merge 1 commit into
voxpupuli:masterfrom
jcpunk:exec-list
Closed

allow Exec to be a String or Array of Strings#106
jcpunk wants to merge 1 commit into
voxpupuli:masterfrom
jcpunk:exec-list

Conversation

@jcpunk

@jcpunk jcpunk commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

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

@jcpunk jcpunk added the enhancement New feature or request label Apr 21, 2026
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.
super().merge(
container_entry: {
'Image' => 'prom/node-exporter:latest',
'Exec' => [

@traylenator traylenator Apr 22, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unaware of Block Scalers. That is better than this magic.

@jcpunk jcpunk closed this Apr 22, 2026
@jcpunk
jcpunk deleted the exec-list branch April 22, 2026 13:20
@jcpunk

jcpunk commented Apr 22, 2026

Copy link
Copy Markdown
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants