During a recent change i added a new custom type Wmflib::Site to validate site parameters and the question that came back was do we really need a new hardcoded list of sites. My response was
Personally i think it makes sense to have a datatype to validate the site (and going back to the previous discussion i actually prefer datacenteres as a name). however i take your point that we allready have this defined in multiple places. from my PoV (and without looking at all the use cases) i think we should:
- move the site global parameter to a fact (and rename it datacenter)
- have the values hardcoded here so we can validate parameters
- create a function something like the following for when other classes profiles need to know the list of sites (this would also need to have the hard coded list)
function wmflib::get_datacenters( Enum['cache', 'primary', 'all'] $dc_type = 'all' ) { $datacenters { 'eqiad' => 'primary', 'codfw' => 'primary', 'esams' => 'cache', 'ulsfo' => 'cache', 'eqsin' => 'cache', } if $dc_type = 'all' { $datacenters.keys else { $datacenters.filter |key, value| { $value = $dc_type }.keys } }
Which also touch on another topic that cam up as to wether we should use the name datacenters over site. Site has in some versions of puppet been a reserved word so i would prefer to go with datacenteres. Also if we do this by adding a new fact then we could slowly migrate which should provide an easy pathforward