really nice workaround, thanks!

On Mon, Jul 14, 2014 at 3:29 PM, jcbollinger <[email protected]>
wrote:

>
>
> On Saturday, July 12, 2014 6:05:35 AM UTC-5, Jose Luis Ledesma wrote:
>>
>> Hi all,
>>
>>     I have found a problem setting up exported resources. The problem is
>> that for every hosts I want to define in its /etc/hosts the primary ip, but
>> I want to export a secondary ip with the same hostname that will be
>> collected just by one server. So I defined:
>>
>>
>>
>> @@host { $::hostname :
>>
>>   ensure  => present,
>>
>>   ip      => $secondary_ip,
>>
>> }
>>
>>
>>
>> host { $::hostname :
>>
>>   ensure  => present,
>>
>>   ip      => $primary_ip
>>
>> }
>>
>>
>>
>>
>>
>> but when I launch puppet a duplicated resource arises:
>>
>>
>>
>> # puppet agent -t
>>
>> Info: Retrieving plugin
>>
>> Error: Could not retrieve catalog from remote server: Error 400 on
>> SERVER: Duplicate declaration: Host[XXXXX] is already declared in file
>> /etc/puppet/manifests/init.pp:15; cannot redeclare at
>>  /etc/puppet/manifests/init.pp:5 on node XXXX
>>
>> Warning: Not using cache on failed catalog
>>
>> Error: Could not retrieve catalog; skipping run
>>
>>
>>
>> I have just implemented a workaround:
>>
>>
>> @@host { "${::hostname}-secondary" :
>>
>>   ensure  => present,
>>
>>   ip      => $secondary_ip,
>>
>>   host_alises => $::hostname,
>>
>> }
>>
>>
>>
>> but I wanted to know if there is a better solution.
>>
>>
>>
>
> It may be possible to wrap the duplicate Host resource in an exported
> defined type instance:
>
> define site::secondary_host ($ip, $ensure = 'present') {
>   host { $title: ip => $ip, ensure => $ensure }
> }
>
> @@site::secondary_host { ${::hostname}:
>   ip => $secondary_ip
> }
>
> You will not be able to collect that resource on the node that exports it
> (you would again -- and rightfully -- get a duplicate resource complaint),
> but I think otherwise you should be ok.  Specifically, I think Puppet will
> avoid evaluating the definition body for instances that are exported, until
> and unless they are collected.  If that indeed works then it may be a bit
> better than your solution because it makes the node's hostname the primary
> name of the hosts entry, rather than an alias.
>
>
> John
>
>  --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/b2350416-f2aa-4e0c-8f90-a8c31021e37e%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/b2350416-f2aa-4e0c-8f90-a8c31021e37e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
José Luis Ledesma

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAF_B3de27UAH6oWRAjLGp0fooTLc1f_NUb-TSeqJngWkSA%2BpnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to