code: def determine_apache_port(public_port, singlenode_mode=False):
      '''
      Description: Determine correct apache listening port based on public IP +
      state of the cluster.
  
      public_port: int: standard public port for given service
  
      singlenode_mode: boolean: Shuffle ports when only a single unit is present
  
      returns: int: the correct listening port for the HAProxy service
      '''
      i = 0
      if singlenode_mode:
          i += 1
      elif len(peer_units()) > 0 or is_clustered():
          i += 1
      return public_port - (i * 10f determine_apache_port(public_port, singlenode_mode=False):
      '''
      Description: Determine correct apache listening port based on public IP +
      state of the cluster.
  
      public_port: int: standard public port for given service
  
      singlenode_mode: boolean: Shuffle ports when only a single unit is present
  
      returns: int: the correct listening port for the HAProxy service
      '''
      i = 0
      if singlenode_mode:
          i += 1
      elif len(peer_units()) > 0 or is_clustered():
          i += 1
      return public_port - (i * 10)
docs: Description: Determine correct apache listening port based on public IP +
      state of the cluster.
  
      public_port: int: standard public port for given service
  
      singlenode_mode: boolean: Shuffle ports when only a single unit is present
  
      returns: int: the correct listening port for the HAProxy service