Skip to content

Instantly share code, notes, and snippets.

@WhatsARanjit
Created June 30, 2017 15:13
Show Gist options
  • Save WhatsARanjit/94a73f036ef899ad4612bc7a8fb2446a to your computer and use it in GitHub Desktop.
Save WhatsARanjit/94a73f036ef899ad4612bc7a8fb2446a to your computer and use it in GitHub Desktop.
Sharing data by jacking exported resources
[root@puppet2017 ~]# cat /tmp/test.pp
$epptemplate = @(EPP/L)
<%- | $nodes | -%>
My nodes:
<% $nodes.each |$n| { -%>
Hostname: <%= $n[0] %>
IP: <%= $n[1] %>
<% } -%>
| EPP
notify { 'Data collected':
message => inline_epp($epptemplate, {
'nodes' => share_data::retrieve('foobar')
}),
}
[root@puppet2017 ~]# puppet apply /tmp/test.pp
Notice: Compiled catalog for puppet2017.1.1.puppetlabs.vm in environment production in 0.25 seconds
Notice:
My nodes:
Hostname: node1
IP: 10.0.2.15
Hostname: puppet2017
IP: 10.0.2.15
Notice: /Stage[main]/Main/Notify[Data collected]/message: defined 'message' as '
My nodes:
Hostname: node1
IP: 10.0.2.15
Hostname: puppet2017
IP: 10.0.2.15
'
Notice: Applied catalog in 0.24 seconds
# Put this somewhere in node's classification
share_data { $fqdn:
data => [ $hostname, $ipaddress ],
label => 'foobar',
}
@WhatsARanjit
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment