Ask Your Question
1

How do I use deeper facts in a template .erb?

asked 2015-07-30 11:15:20 -0500

nm00 gravatar image

I'm using Facter 3.

For example in a message of the day module i'm using this syntax in my .erb template:

  • This system is running: <%= @operatingsystem %> (displays "CentOS")
  • Filesystem Type: <%= @filesystems %> (displays "xfs")

But I want to display the output of the fact: "os => release => full" instead of operatingsystem (to display: "7.1.x")

What is the correct syntax in using a more deeply nested fact in an .erb template?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
6

answered 2015-08-01 04:30:38 -0500

Correct syntax would be

<%= @os['release']['full'] %>
edit flag offensive delete link more

Comments

This is exactly what I was looking for. Thanks!

nm00 gravatar imagenm00 ( 2015-08-04 09:49:38 -0500 )edit
1

answered 2015-07-31 07:54:21 -0500

could you do it with the operatingsystemrelease fact?

edit flag offensive delete link more

Comments

Major: <%= @os['release']['major'] %>
Minor: <%= @os['release']['minor'] %>
Full: <%= @os['release']['full'] %>
or
Major: <%= @facts['os']['release']['major'] %>
Minor: <%= @facts['os']['release']['minor'] %>
Full: <%= @facts['os']['release']['full'] %>

bentlema gravatar imagebentlema ( 2016-11-15 17:41:09 -0500 )edit
0

answered 2015-12-11 05:41:53 -0500

Except this seems not to work. Just tried exactly that syntax.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2015-07-30 11:05:48 -0500

Seen: 2,652 times

Last updated: Aug 01 '15