I've changed your g_C[:mac] to gos[:mac], because I don't know what it
should do and puppet complained about it.

On Tue, Oct 15, 2013 at 4:26 PM, Cristian Falcas
<cristi.fal...@gmail.com> wrote:
> Put in $your_module_name/lib/puppet/parser/functions/am_running_oss.rb
>
>
> module Puppet::Parser::Functions
>     newfunction(:am_running_oss, :type => :rvalue ) do |args|
>         #inFile = "/tmp/OSs.txt"
>         inFile = args[0]
>         gos = {}
>
>         if File.exist?(inFile)
>             open(inFile, 'r').each do |line|
>                 next if line =~ /^\s*(#|$)/
>                 parts = line.split(',').map(&:strip)
>
>                 case parts[1]
>                 when /^Mac/
>                     (gos[:mac] ||= []) << parts[0]
>                     #gos['1']
>                 when /_Win$/
>                     (gos[:win] ||= []) << parts[0]
>                 else
>                     (gos[:linux] ||= []) << parts[0]
>                 end
>             end
>         end
>         if gos.count >= 1
>             return gos.keys.join(',')
>         else
>             return 'undefined'
>         end
>     end
> end
>
> And from your module:
>
> $q=am_running_oss("/tmp/OSs.txt")
> notify {"XXXXXXXX ${q}":}
>
>
> Also, you could skip the parameter and just hard coded in the file.
>
>
>
> On Tue, Oct 15, 2013 at 9:03 AM, Sans <r.santanu....@gmail.com> wrote:
>>
>> Yes, the file is only on the master (and not exactly maintained by the
>> Puppet but the provisioning framework) and it looks something like this:
>>
>>
>>> Slackware, Linux, i-num=1
>>> Jaguar, MacX, i-num=6
>>> Chicago, this_Win, i-num=2
>>> Daytona, an_other_Win, i-num=7
>>> RedHat, Linux, i-num=5
>>> Lion, MacY, i-num=4
>>> Caldera, Linux, i-num=9
>>> Longhorn, that_Win, i-num=8
>>> Tiger, MacZ, i-num=3
>>> Indiana, Solaris, i-num=10
>>> Kodiak, MacX, i-num=11
>>
>>
>>
>> What I was trying to do is to get a fact (or function) that returns a string
>> like: "win,mac,linux", as I showed in my previous post. Really appreciate if
>> you can make an example function out of that. cheers!!
>>
>>
>>
>>
>> On Monday, October 14, 2013 9:37:51 PM UTC+1, Cristian Falcas wrote:
>>>
>>> i understood that the file is only on the master? If so, I will try to
>>> write something tomorrow to implement this,
>>>
>>> If the value never changes, it will be better to put it in an external
>>> variable.
>>>
>> --
>> 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 post to this group, send email to puppet-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/puppet-users.
>> 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 post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to