<p>Given the following appliction.conf :</p>
<pre><code>akka {
  loglevel = debug
  actor {
    provider = cluster

    serialization-bindings {
      &quot;sample.cluster.CborSerializable&quot; = jackson-cbor
    }
  }
  remote {
    artery {
      canonical.hostname = &quot;127.0.0.1&quot;
      canonical.port = 0
    }
  }
  cluster {
roles= [&quot;testrole1&quot; , &quot;testrole2&quot;]
    seed-nodes = [
      &quot;akka://ClusterSystem@127.0.0.1:25251&quot;,
      &quot;akka://ClusterSystem@127.0.0.1:25252&quot;]
    downing-provider-class = &quot;akka.cluster.sbr.SplitBrainResolverProvider&quot;
  }
}
</code></pre>
<p>To discern between the roles within an Actor I use :</p>
<pre><code>void register(Member member) {

if (member.hasRole(&quot;testrole1&quot;)) {
 //start actor a1
}
else if (member.hasRole(&quot;testrole2&quot;)) {
 //start actor a2
}
}
</code></pre>
<p>edited from src (<a href="https://doc.akka.io/docs/akka/current/cluster-usage.html" rel="nofollow noreferrer">https://doc.akka.io/docs/akka/current/cluster-usage.html</a>)</p>
<p>To enable role for a node I use the following config :</p>
<p>Within application.conf I configure the array for the roles but this appears to be at the cluster level rather than node level. In other words it does not seem possible to configure application.conf such that the Akka cluster is instructed to start actor a1 on node n1 and actor a2 on node n2? Should note details be specified at the level of akka.cluster in application.conf ?</p>
<p>For each node, is it required to specify multiple application.conf configuration files?</p>
<p>For example, application.conf for testrole1</p>
<pre><code>akka {
  loglevel = debug
  actor {
    provider = cluster

    serialization-bindings {
      &quot;sample.cluster.CborSerializable&quot; = jackson-cbor
    }
  }
  remote {
    artery {
      canonical.hostname = &quot;127.0.0.1&quot;
      canonical.port = 0
    }
  }
  cluster {
roles= [&quot;testrole1&quot;]
    seed-nodes = [
      &quot;akka://ClusterSystem@127.0.0.1:25251&quot;,
      &quot;akka://ClusterSystem@127.0.0.1:25252&quot;]
    downing-provider-class = &quot;akka.cluster.sbr.SplitBrainResolverProvider&quot;
  }
}
</code></pre>
<p>application.conf for testrole2 :</p>
<pre><code>akka {
  loglevel = debug
  actor {
    provider = cluster

    serialization-bindings {
      &quot;sample.cluster.CborSerializable&quot; = jackson-cbor
    }
  }
  remote {
    artery {
      canonical.hostname = &quot;127.0.0.1&quot;
      canonical.port = 0
    }
  }
  cluster {
roles= [&quot;testrole2&quot;]
    seed-nodes = [
      &quot;akka://ClusterSystem@127.0.0.1:25251&quot;,
      &quot;akka://ClusterSystem@127.0.0.1:25252&quot;]
    downing-provider-class = &quot;akka.cluster.sbr.SplitBrainResolverProvider&quot;
  }
}
</code></pre>
<p>The difference between each application.conf defined above is the value of <code>akka.cluster.roles</code> is either &quot;<code>testrole1&quot;</code> or <code>&quot;testrole2&quot;</code>.</p>
<p>How should application.conf be configured such that the Akka cluster is instructed to start actor a1 on node n1 and actor a2 on node n2? Should node details be specified at the level of akka.cluster in application.conf ?</p>
<p>Update:</p>
<p>Another option is to pass the rolename via an environment variable? I've just noticed this is explicitly stated here: <a href="https://doc.akka.io/docs/akka/current/typed/cluster.html" rel="nofollow noreferrer">https://doc.akka.io/docs/akka/current/typed/cluster.html</a> &quot;The node roles are defined in the configuration property named akka.cluster.roles and typically defined in the start script as a system property or environment variable.&quot; In this scenario, use the same application.conf file for all nodes but each node uses an environment variable. For example, an updated appliction.conf (note addition of &quot;ENV_VARIABLE&quot;)</p>
<pre><code>akka {
  loglevel = debug
  actor {
    provider = cluster

    serialization-bindings {
      &quot;sample.cluster.CborSerializable&quot; = jackson-cbor
    }
  }
  remote {
    artery {
      canonical.hostname = &quot;127.0.0.1&quot;
      canonical.port = 0
    }
  }
  cluster {
roles= [&quot;ENV_VARIABLE&quot;]
    seed-nodes = [
      &quot;akka://ClusterSystem@127.0.0.1:25251&quot;,
      &quot;akka://ClusterSystem@127.0.0.1:25252&quot;]
    downing-provider-class = &quot;akka.cluster.sbr.SplitBrainResolverProvider&quot;
  }
}
</code></pre>
<p>Cluster startup scripts determine the role for each node via the <code>ENV_VARIABLE</code> parameter, is this a viable solution?</p>

<p>If you're going to assign different roles to different nodes, those nodes cannot use the same configuration.  The easiest way to accomplish this is through n1 having <code>&quot;testRole1&quot;</code> in its <code>akka.cluster.roles</code> list and n2 having <code>&quot;testRole2&quot;</code> in its <code>akka.cluster.roles</code> list.</p>
<p>Everything in <code>akka.cluster</code> config is only configuring that node for participation in the cluster (it's configuring the cluster component on that node).  A few of the settings have to be the same across the nodes of a cluster (e.g. the SBR settings), but a setting on n1 doesn't affect a setting on n2.</p>
