I’m not quite sure I understand the question, but, you assign the node roles in the config during start up, like you show in application.conf, and then you can access it through the cluster extension, like so:
Set<String> roles = Cluster.get(actorSystem).getSelfRoles();
Was this the question, or is it how to dynamically construct the config you start the actor system with?