Hosts are displayed with a Rack ID. Using the bulk Actions menu, you can Set Rack.

The Rack ID is stored in Ambari and included with the HDFS configuration as part of
configuirng the cluster topolocy for HDFS. The HDFS hdfs-site configuration property
net.topology.script.file.name
executes a topology script that is distributed by Ambari. That
script (when executed by HDFS) reads the /etc/hadoop/conf/topology_mappings.data
file. This
file includes the hostname-to-rack mapping generated by Ambari.
When setting the Rack, HDFS service is updated to have the latest topology host mapping.