# Fact which specifies the name of the vDC of a node

Facter.add("vdc") do
  setcode do
    env_octet = Facter.value(:ipaddress).split('.')[2].to_i
    vdc = Facter.value(:domain).split('.').first
    if env_octet > 7
      vdc + '_dr'
    else
      vdc
    end
  end
end

# Fact which specifies the name of the vDC of a node

Facter.add("vdc") do
  setcode do
    Facter.value(:domain).split('.').first
  end
end

Remove logic for inferring membership of the DR VDCs.
Remove logic for inferring membership of the DR VDCs.

The disaster-recovery VDCs (VMWare "virtual datacentres") no longer
exist; they were part of the old VMWare-based installation when parts of
GOV.UK were hosted in Carrenza and UKCloud.

This logic had a bug where the heuristic for telling whether a machine
was a DR machine or not was based on the IP address of whichever network
interface happens to be returned as `:ipaddress`. For VMs which have
Docker installed on them, this can be the host address on the Docker
network rather than the VM's eth0 interface. So the logic then has a
1 - 7/256 ≈ 97% chance of wrongly appending `_dr` to the value of the
`:vdc` Puppet fact for that node.

This would have gone harmlessly unnoticed, except that
/modules/icinga/manifests/client.pp:51 uses the presence of the `_dr` as
another heuristic to infer that it should add the (long-since-deleted)
VPN gateway for the corresponding (also long-since deleted) VDC as a
"parent" to the node's host configuration in Icinga. This causes Icinga
to fail to start up because it fails to validate its configuration,
which breaks pretty much all the monitoring in the whole environment.
