Ask Your Question
0

Gather all ip addresses

asked 2014-11-01 12:16:16 -0600

Glueon gravatar image

updated 2014-11-01 12:17:42 -0600

Is it possible to extract all IP addresses from facts? I see that there are facts like ipaddress_eth0, ipaddress_eth1 which contain IP address of a certain interface.

Also there is interfaces fact which lists all interfaces I have. Then in order to get all IPs i need to take interfaces from the interfaces fact and iterate over ipaddress_$interface?

For example to write then to the file like:

file { '/etc/allIPs' : content => $allIPs }

Or maybe there is a syntax to retrieve facts which match certain regexp, like interface_.+ and then glue them together?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-11-01 20:29:28 -0600

jonuwz gravatar image
$template='<% scope["::interfaces"].split(",").each do |int| -%>
<%= scope["::ipaddress_#{int}"] %>
<%- end -%>'

file{'/tmp/allIPs':
  ensure => file,
  content => inline_template($template),
}
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

1 follower

Stats

Asked: 2014-11-01 12:16:16 -0600

Seen: 461 times

Last updated: Nov 01 '14