On Friday, December 28, 2012 3:32:43 PM UTC-6, Rafi
wrote:>
> I am using a masterless puppet 3.0 setup with EC2. Using extlookup, I
> intend to set a more meaningful hostname than the usual ip* and dom* names
> assigned by Amazon.
>
> My source csv file is setup as:
>
> publicdns,name
> ec2-184-73.compute-1.amazonaws.com,server-1
> ec2-23-20.compute-2.amazonaws.com,server-2
>
>
> In my hostname/init.pp file, I wanted to use *$instancename =
> extlookup($ec2_public_hostname, ''undefined'',$csv)* to
return the second
> value in the row, but it instead returns the default value, i.e. it
> didn''t find it.
>
That is likely an issue with your data.
>
> When I use* **$instancename = extlookup(''publicdns'',
''undefined'',$csv)*,
> it returns the concatenated "ec2-184-73.compute-1.amazonaws.com
> ec2-23-20.compute-2.amazonaws.com". Similarly, when I use
*$instancename
> = extlookup(''name'', ''undefined'',$csv)*,
it returns the value
> "server-1server-2".
>
You are probably getting an array from extlookup. It gets flattened when
you coerce it to a string for printing.
>
> This isn''t consistent with how I understand extlookup to work,
since I
> thought it is supposed to read across rows, not columns. How should I
> identify and properly extract the second field of a given row?
>
Since you are using Puppet 3, I strongly recommend that you use hiera
instead of extlookup. I don''t remember whether extlookup has formally
been deprecated, but certainly hiera is in every way its successor. Look
here to get started with hiera: https://github.com/puppetlabs/hiera. Ask
on this group if you want help with hiera.
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/npYtvEmWCCgJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.