How to deliberately cause modules to conflict?

18 views
Skip to first unread message

Dan Mahoney, System Admin

unread,
May 28, 2016, 7:19:19 PM5/28/16
to puppet...@googlegroups.com
Hey there.

This is a weird question, but I guess I'll ask it anyway.

Is there a way to say one of the following two things?

1) That you want a manifest to deliberately break when you try to include
two different items? For example, most of our machines run a very simple
mailer called DMA (dragonfly mail agent), but some machines (which handle
inbound mail) require full blown postfix. I'd love for the manifest to
simply refuse to operate. Since there's no common files between them,
right now if you try to install both, you'll just have a bunch of Augeas
changes required for each MTA being made back and forth.

2) To say that if I've installed the "postfix" module, that it basically
de-includes the "dma" class from the manifest?

I realize I could in fact create an "mta" class which installs dma by
default, but parameterize it such that postfix is another option. Are
there any other ways?

-Dan

--

--------Dan Mahoney--------
Techie, Sysadmin, WebGeek
Gushi on efnet/undernet IRC
ICQ: 13735144 AIM: LarpGM
Site: http://www.gushi.org
---------------------------

Rob Nelson

unread,
May 28, 2016, 7:53:46 PM5/28/16
to puppet...@googlegroups.com
You could test for the other class and fail, something like 

if Defined(Class['dma'])
  Fail "you cannot use postfix with dma"

Typed from my phone, please check syntax and caps and such. 


--

jcbollinger

unread,
May 31, 2016, 9:47:31 AM5/31/16
to Puppet Users


On Saturday, May 28, 2016 at 6:19:19 PM UTC-5, Dan Mahoney wrote:
Hey there.

This is a weird question, but I guess I'll ask it anyway.

Is there a way to say one of the following two things?

1) That you want a manifest to deliberately break when you try to include
two different items?


Rob already mentioned using the defined() function to test whether a key class of the competing module has already been declared.  Do note (lack of) capitalization.  More importantly, be aware that for this strategy to work, it needs to be mutual -- each module needs to exclude the other.  If it were not mutual, then it would be possible to declare both modules in the same catalog despite the test, as long the declarations were evaluated in the correct order.

Another alternative would be to choose some specific resource that has no corresponding physical resource, and have both modules declare that resource.  If both modules are included then catalog building will fail with a duplicate declaration error.  That, too, needs to be mutual, of course.  I like this alternative better because it seems a better match to Puppet's resource-centric model.


2) To say that if I've installed the "postfix" module, that it basically
de-includes the "dma" class from the manifest?



No.  During catalog building, including a class or resource in the catalog is irreversible.  This is a good reason to implement ideas such as yours to abstract MTA management to one class that chooses which system to use based on data.  I like the kind of mutual exclusion you asked about better as a backstop for such an approach than as a primary mechanism.


John

Reply all
Reply to author
Forward
0 new messages