One option is to save dd_code lines as a separate script, have puppet ensure 
its presence on each machine with a file statement, and then call it by 
explicit path in the Facter.add block.

--
Peter (from phone)

On Jun 14, 2011, at 7:39 AM, Sans <r.santanu....@gmail.com> wrote:

> Dear all,
> 
> I see that writing a custom-fact with single line of command is not
> that tough, like this:
> 
> ****************************
> Facter.add("num_core") do
>    setcode do
>        %x{/bin/grep siblings /proc/cpuinfo | uniq | cut -d" " -f
> 2}.chomp
>    end
> end
> ****************************
> 
> But that's not enough for me. What I actually need to do is something
> like this:
> 
> dd_code=`which dmidecode`
> n1=`${dd_code} -t processor | grep -c "Socket Designation"`
> n2=`${dd_code} -t processor | grep "Core Count" | uniq | cut -d" " -
> f3`
> n=$(($n1*$n2))
> 
> 
> How can I put this in the "fact"? Cheers!!
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/puppet-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to