Resource: destroy before create?

44 views
Skip to first unread message

Andreas Schuster

unread,
Jun 27, 2014, 8:45:49 AM6/27/14
to puppet...@googlegroups.com

Hi all,

 

i have written a own resource type to manage Interfaces, ipaddresses and mor on Solaris systems.

I also enabled purging for the ipaddress resources to destroy no longer included ipaddresses in a catalogue for a system.

All works fine and without problems.

But in some rare situations, he wants to create a Ipinterface with a Ipaddress before he destroys an other, not in catalogue included ipaddress.

Is there a option to configure that he first  always destroys resources that not included in the catalogue?

 

Example:

Ip configure on Interface: e1000g1/v4

Ip in catalogue on Interface: ipmp1/v4

During first Puppet run i got this error:

Error: /Stage[network]/Network::Solaris::Ip_address/Network::Solaris::Def_ipaddress[ipmp1/v4]/Ipaddress[ipmp1/v4]/ensure: change from absent to present failed: ip='1.2.3.4' already exists!

Notice: /Ipaddress[e1000g1/v4]/ensure: removed

As you coold see, he tries first to create and then a destroy on the other resource.
Now i need a second puppet run to create failed resources. :-(

 

Any idea how to implement such ordering: destroy before create?

Is it true, that Puppet execute Reources of the same resorce type sequential?

Regards

Andreas

 

jcbollinger

unread,
Jun 30, 2014, 1:32:23 PM6/30/14
to puppet...@googlegroups.com


I suppose you are using the Resources meta-resource type to perform your purging.  I think you can achieve what you're after by setting up appropriate relationships between that meta-resource and your Ipaddress resources, either via the 'require' and/or 'before' metaparameters, or via the chain operators.  I'd probably try declaring the resource purge something like this:

resources { 'ipaddress': purge => true }
  -> Ipaddress<| |>

If for some reason you need to separate declaration of the Resources resource from declaration of the relationships, then you could instead put this almost anywhere:

Resources['ipaddress'] -> Ipaddress<| |>

You could also make each Ipaddress declaration 'require' Resources['ipaddress'], but that's a little lumpier.


John

Andreas Schuster

unread,
Jul 7, 2014, 12:05:50 PM7/7/14
to puppet...@googlegroups.com
Hi John,

many thanks for your answer. It was really helpful. But i must make one modificatiotion:

resources { 'ipaddress':
  purge => true,
} -> Ipaddress<| enusre == absent |>

Now this works really fine and he purges before he creates new resources/Ipaddresses :-)

Regrads,
Andreas

Reply all
Reply to author
Forward
0 new messages