Re: [Puppet Users] Hiera in custom facts?

2013-12-08 Thread Johan De Wit
Trying to explain a little bit more, here is the flow of a puppet run on 
a node :


On the node : agent starts - gathers all the facts.  ( facter -p if you 
want to see what is gathered)

Node sends it to the puppet master
Puppet masters compiles the catalog, using those facte, and looking up 
all classes assigned to that node. It is here hiera comes in action.

Compiled catalog is send to the Node
Node executes the catalog, and sends a report back to the puppet master

I hope you see now why hiera and facts dont work together

grts

jo





On 12/06/2013 04:13 PM, Felix Frank wrote:

Again: You *cannot* get hiera values into facter, nor would that be
particularly useful (at least from the master's perspective).

On 12/06/2013 04:08 PM, leed wrote:

Thanks for your response, I'd tried adding that to the global scope
(confirmed with a notify), but this doesn't seem to be passed to the
custom facts, as these seem to be processed before hand?

So with

Facter.add(cluster_name) do
   setcode do
 $clustername
   end
end

I get :-

# facter --debug -p
value for cluster_name is still nil



--
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer (805008667232363)
Puppet Certified Professional 2013 (PCP006)
_
 
Open-Future Phone +32 (0)2/255 70 70

Zavelstraat 72  Fax   +32 (0)2/255 70 71
3071 KORTENBERG Mobile+32 (0)474/42 40 73
BELGIUM http://www.open-future.be
_
 


Next Events:
Puppet Fundamentals Training | 
http://www.open-future.be/puppet-fundamentals-training-10-till-12th-december
Puppet Advanced Training | 
http://www.open-future.be/puppet-advanced-training-7-till-9th-january
Puppet Fundamentals Training | 
http://www.open-future.be/puppet-fundamentals-training-4-till-6th-february
Subscribe to our newsletter | http://eepurl.com/BUG8H

--
You received this message because you are subscribed to the Google Groups Puppet 
Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/52A46245.4070301%40open-future.be.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Puppet Users] Hiera in custom facts?

2013-12-08 Thread Lee Dormon

Excellent,  thanks guys, had a feeling I was doing it wrong, just wanted to 
make sure.

Thanks
Lee

On 8 Dec 2013, at 12:12, Johan De Wit jo...@open-future.be wrote:

 Trying to explain a little bit more, here is the flow of a puppet run on a 
 node :
 
 On the node : agent starts - gathers all the facts.  ( facter -p if you want 
 to see what is gathered)
 Node sends it to the puppet master
 Puppet masters compiles the catalog, using those facte, and looking up all 
 classes assigned to that node. It is here hiera comes in action.
 Compiled catalog is send to the Node
 Node executes the catalog, and sends a report back to the puppet master
 
 I hope you see now why hiera and facts dont work together
 
 grts
 
 jo
 
 
 
 
 
 On 12/06/2013 04:13 PM, Felix Frank wrote:
 Again: You *cannot* get hiera values into facter, nor would that be
 particularly useful (at least from the master's perspective).
 
 On 12/06/2013 04:08 PM, leed wrote:
 Thanks for your response, I'd tried adding that to the global scope
 (confirmed with a notify), but this doesn't seem to be passed to the
 custom facts, as these seem to be processed before hand?
 
 So with
 
 Facter.add(cluster_name) do
   setcode do
 $clustername
   end
 end
 
 I get :-
 
 # facter --debug -p
 value for cluster_name is still nil
 
 
 -- 
 Johan De Wit
 
 Open Source Consultant
 
 Red Hat Certified Engineer (805008667232363)
 Puppet Certified Professional 2013 (PCP006)
 _
 Open-Future Phone +32 (0)2/255 70 70
 Zavelstraat 72  Fax   +32 (0)2/255 70 71
 3071 KORTENBERG Mobile+32 (0)474/42 40 73
 BELGIUM http://www.open-future.be
 _
 
 Next Events:
 Puppet Fundamentals Training | 
 http://www.open-future.be/puppet-fundamentals-training-10-till-12th-december
 Puppet Advanced Training | 
 http://www.open-future.be/puppet-advanced-training-7-till-9th-january
 Puppet Fundamentals Training | 
 http://www.open-future.be/puppet-fundamentals-training-4-till-6th-february
 Subscribe to our newsletter | http://eepurl.com/BUG8H
 
 -- 
 You received this message because you are subscribed to a topic in the Google 
 Groups Puppet Users group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/puppet-users/QvE8YCSi0co/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 puppet-users+unsubscr...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/puppet-users/52A46245.4070301%40open-future.be.
 For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/430B5346-6108-407D-84C5-FC871384AE9F%40dormon.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Puppet Users] Hiera in custom facts?

2013-12-06 Thread leed

Hello all

So is it possible to use hiera data in a custom facts? I'm probably going 
about this all wrong, but I was hoping something like this would work.

Facter.add(cluster_name) do
  setcode do
   hiera('clustername')
  end
end

But I get a lot of

Could not retrieve cluster_name: undefined method `hiera' for 
:Facter::Util::Resolution

The fact that googling for this returns nothing is whats making me worried 
I'm going about it all wrong.

Just want to be able to have a custom fact that returns the cluster_name 
for a host if its set in its hiera data.

Cheers
Lee



-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/ac9f9f5f-36f5-4b5d-91a6-02ae5335685a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Puppet Users] Hiera in custom facts?

2013-12-06 Thread Felix Frank
Hi,

this is in fact not the right approach.

Facts are evaluated on the agent side, while hiera typically belongs to
the master side only.

If you want to use $clustername instead of hiera(clustername), just
add this to the global scope of your manifest:

$clustername = hiera(clustername)

HTH,
Felix

On 12/06/2013 02:09 PM, leed wrote:
 
 Hello all
 
 So is it possible to use hiera data in a custom facts? I'm probably
 going about this all wrong, but I was hoping something like this would work.
 
 Facter.add(cluster_name) do
   setcode do
hiera('clustername')
   end
 end
 
 But I get a lot of
 
 Could not retrieve cluster_name: undefined method `hiera' for
 :Facter::Util::Resolution
 
 The fact that googling for this returns nothing is whats making me
 worried I'm going about it all wrong.
 
 Just want to be able to have a custom fact that returns the cluster_name
 for a host if its set in its hiera data.
 
 Cheers
 Lee

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/52A1DEE3.5030909%40alumni.tu-berlin.de.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Puppet Users] Hiera in custom facts?

2013-12-06 Thread leed
On Friday, 6 December 2013 14:27:47 UTC, Felix.Frank wrote:


 If you want to use $clustername instead of hiera(clustername), just 
 add this to the global scope of your manifest: 

 $clustername = hiera(clustername) 


Thanks for your response, I'd tried adding that to the global scope 
(confirmed with a notify), but this doesn't seem to be passed to the custom 
facts, as these seem to be processed before hand?

So with 

Facter.add(cluster_name) do
  setcode do
$clustername
  end
end

I get :-

# facter --debug -p
value for cluster_name is still nil

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/f3c1f141-6553-48cc-b7d9-5da102c1d71a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Puppet Users] Hiera in custom facts?

2013-12-06 Thread Felix Frank
Again: You *cannot* get hiera values into facter, nor would that be
particularly useful (at least from the master's perspective).

On 12/06/2013 04:08 PM, leed wrote:
 Thanks for your response, I'd tried adding that to the global scope
 (confirmed with a notify), but this doesn't seem to be passed to the
 custom facts, as these seem to be processed before hand?
 
 So with 
 
 Facter.add(cluster_name) do
   setcode do
 $clustername
   end
 end
 
 I get :-
 
 # facter --debug -p
 value for cluster_name is still nil

-- 
You received this message because you are subscribed to the Google Groups 
Puppet Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/52A1E994.8050609%40alumni.tu-berlin.de.
For more options, visit https://groups.google.com/groups/opt_out.