I think there are at least three ways to handle this, and all of them have their valid uses:
1) Explicitly include the worker profile in every role but the master role
- pro: you need no logic to disable the worker profile in the master role
- con: A lot of repetition in the other roles
2) Add a "disable switch" hiera variable to the worker profile and then include it in the base.pp. For the master node, you disable the worker profile via the hiera switch and explicitly include the master profile
- pro: It is possible to include the
- con: You need to wrap the code in the worker profile into a large if not $disabled { ... } clause
3) Create a wrapper profile for master and worker that conditionally, depending on a hiera variable, load one class or the other. That variable could be a $service_type = master|worker enum or the fqdn of the master server to compare again in the wrapper class if the master name is already needed i.e. for configuring the workers: if $facts['fqdn'] == $mastername { include profile::service::master } else { include profile::service::slave }
- pro: You need only a single include in the role or base.pp for every server somehow related to that service, be it master or worker
- con: In the role class it is not directly visible if the server is a master or a worker.
Which one of these to use (if any) depends on your preferences and situation, of course.
Best regards
Karsten