0

I am looking the way to have the result of this ruby template file:

ServerName 1.server.foo

knowing that if I run

$ facter -p fqdn
1.server.foo.internet.com

I would probably play with <%= @fqdn %> and .gsub?

server-id: <%= @fqdn %>.gsub(/.internet.com/, '')
nerabis
  • 25
  • 1
  • 8
  • oobs. seems not working well . `server-id: 01.server.foo.internet.com.gsub(/\.internet.comt/b/, '')` – nerabis Feb 25 '20 at 13:56

2 Answers2

2

The entire expression needs to be in the <%= %> tag, so try

server-id: <%= @fqdn.regsubst(/.internet.com/, '') %>

The template syntax is documented at https://puppet.com/docs/puppet/5.5/lang_template_erb.html with examples of expressions used in <%= %> tags.

I'd also note that ERB templates have been replaced by native Embedded Puppet EPP templates, so it may be better to convert now.

Jon
  • 3,573
  • 2
  • 17
  • 24
  • am trying with EPP. `server-id: <%= $facts[fqdn].gsub(/.internet.com/, '') %>;` but, he do not like. Unknown function: 'gsub' – nerabis Feb 25 '20 at 17:29
0

using EPP with regsubst it works!

server-id: <%= $facts[fqdn].regsubst(/.internet.com/, '') %>
nerabis
  • 25
  • 1
  • 8