diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 417f924d4e14..fc2a37ce1ab9 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -5490,6 +5490,13 @@ def get_field_from_model_or_attrs(fd): if peers_from_control_nodes and node_type not in (Instance.Types.EXECUTION, Instance.Types.HOP): raise serializers.ValidationError("peers_from_control_nodes can only be enabled for execution or hop nodes.") + + if node_type in (Instance.Types.CONTROL): + if self.instance and 'peers' in attrs and set(self.instance.peers.all()) != set(attrs['peers']): + raise serializers.ValidationError( + "Setting peers manually for control nodes is not allowed. Enable peers_from_control_nodes on the hop and execution nodes instead." + ) + return super().validate(attrs) def validate_node_type(self, value):