0

Is it possible to get memory value in Puppet/YAML? I would like to calculate max_memory_usage value in this YAML file.

...
clickhouse::server::profiles:
  production:
    max_memory_usage: "ceiling %{facts.memory.system.total_bytes} * 0.7"
...

Thank in advance

Matthew Schuchard
  • 25,172
  • 3
  • 47
  • 67
  • Why do you want to do this in YAML instead of Puppet? – Matthew Schuchard Mar 13 '19 at 17:58
  • I started to learn how to use hiera and build new environments. And I am experimenting if YAML good for nodes. – Rostyslav Malenko Mar 13 '19 at 18:07
  • Ok; this is just a normal use case for code and not data, so you are making this extra difficult for yourself. If you want to go this route for learning purposes, then good luck. – Matthew Schuchard Mar 13 '19 at 18:59
  • I think you are right. YAML's nodes aren't the easiest way to stars :) – Rostyslav Malenko Mar 13 '19 at 19:47
  • Are you asking about Hiera and [its interpolation capabilities](https://puppet.com/docs/puppet/5.5/hiera_merging.html#interpolation), or more generally about Puppet and YAML? Hiera's standard back end for YAML does not perform the sort of computation you describe. – John Bollinger Mar 13 '19 at 20:53
  • @JohnBollinger - I can get memory uses `%{facts.memory.system.total_bytes}` and I would like to calculate 70% of this value and get an integer value without the period. Is it possible in YAML format? – Rostyslav Malenko Mar 13 '19 at 21:17
  • @RostyslavMalenko, YAML itself has no computational capabilities at all. It is strictly a language for representing data. Even interpolation of `%{facts.memory.system.total_bytes}` is a behavior of Puppet's "Hiera" subsystem, not of YAML. Hiera supports pluggable back ends, but the standard one for YAML does not have the feature you're looking for. But you might get that with a custom Hiera back end or with some other YAML processor that is not Hiera-associated. That's why I asked for clarification. – John Bollinger Mar 13 '19 at 21:22
  • 1
    Possible duplicate of [Do basic math inside Hiera](https://stackoverflow.com/questions/28775785/do-basic-math-inside-hiera) – Alex Harvey Mar 14 '19 at 11:56
  • 1
    In case someone then asks if the feature has been added to Hiera to in the four years since that proposed duplicate question, the answer is: no. – Matthew Schuchard Mar 14 '19 at 12:32

0 Answers0