Unable to generate process-exporter.yaml config with mapping character (=>)
To generate the config (/etc/process-exporter.yaml), this module exposes watched_processes of type array, that is dumped to yaml here:
https://github.com/voxpupuli/puppet-prometheus/blob/master/templates/process-exporter.yaml.erb#L2
The problem is that I don't believe an array is sufficient, and we should be able to specify the content of the file as a string.
The array is not sufficient because the value must contain arrow => characters to map values and => is not escapable. Or of course, I have missed the documentation on escaping an =>.
doc: https://yaml.org/YAML_for_ruby.html
This is the expected output via cli:
$ irb
irb(main):001:0> require 'yaml'
irb(main):002:0> puts YAML.dump({"process_names"=> ["name" => "{{.Comm}}", "cmdline" => [".+"]] })
---
process_names:
- name: "{{.Comm}}"
cmdline:
- ".+"
=> nil
irb(main):003:0>
but puppet creates this error:
class { 'prometheus::process_exporter':
version => '0.5.0',
watched_processes => [ "name" => "{{.Comm}}", "cmdline" => [".+"]]
}
Error while evaluating a Resource Statement, Syntax error at '=>' at /etc/puppetlabs/code/environments/development/modules/profiles/manifests/monitoring/prometheus/process.pp:14:18
When I wrap it in single quotes its interpreted as a single string value.
class { 'prometheus::process_exporter':
version => '0.5.0',
watched_processes => [ '"name" => "{{.Comm}}", "cmdline" => [".+"]']
}
$ cat /etc/process-exporter.yaml
---
process_names:
- '"name" => "{{.Comm}}", "cmdline" => [".+"]'
[root@dban proc]#
Module version: puppet-prometheus v6.0.0
I tried to add the ability to allow the specification of the file content, but I haven't got that working yet. #325