you could use the defined(Class[xy]) function to test if the class is included.

but be aware that you need to control the manifest parse order for that to 
work. if you check defined() before the class is included this wont work.

- Thomas

https://docs.puppet.com/puppet/latest/function.html#defined

Am 5. Oktober 2017 02:36:03 MESZ schrieb James Perry <jjperr...@gmail.com>:
>Thanks Rob.
>>
>>
>As for reclassifying nodes that is a use case outside of what I'm
>trying to 
>accomplish. 
>
>Mostly I was trying to work more a scenario like the following: 
>
>I have a set of restricted accounts for use with ERPM.on Linux. Each
>DBA is 
>assigned a Linux local ERPM user that is the same on all hosts due to
>how 
>ERPM is configured. Each of the ERPM account has specific sudo rules 
>assigned to it using the sudoers module from Puppet Forge. Basically
>each 
>erpm01-erpm30 user has the necessary groups, permissions, home and sudo
>
>rules for that account. Each user is a defined class so we can add 
>individual ones on the host where they are required. I can't set the
>ERPMXX 
>class to absent as that will remove it globally, which we don't want. I
>
>knew ways to work around this, but I'm trying to keep things as clean
>and 
>simple as possible so we don't have to touch the code except to add new
>
>functionality. Our level on admins are given access in Foreman to add
>the 
>class so they need not touch any code. 
>
>-------------------------------------------------------------------
>
>Based on your explanation, how can I query / access the state Puppet
>knows 
>for a host with regard to classes it doesn't have assigned? 
>
>I would like to write code to check for the absence of a class/classes
>and 
>then tell puppet what I want it to mean when the class is absent. Using
>the 
>example above, it would loop through all of the ERPMXX classes to
>detect 
>those that aren't present. When one is found to not be present it would
>
>define the state noting for ensure => absent for that user. If the
>class is 
>there it does nothing for that user. 
>
>Do as you noted in your Example for Apache, packages to know to be 
>installed solely for Apache dependencies could be defined and set
>ensure => 
>"absent" and any other steps required to handle the absence of the
>class. 
>
>I know i don't even have a partial grasp of the intricacies of the
>Puppet 
>internals, so being able to check the state of classes being present or
>
>absent on the host other than from the host's classes.txt file. 
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "Puppet Developers" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to puppet-dev+unsubscr...@googlegroups.com.
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/puppet-dev/1dd6e4f0-fff1-41a8-bad3-7d502a8bae7a%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/DB2F4D5E-B989-4A97-AB57-2DAC9574DE75%40chaschperli.ch.
For more options, visit https://groups.google.com/d/optout.

Reply via email to