Make govuk_node_list more selective
Make govuk_node_list more selective

When passing a list of node classes to `govuk_node_list`, make
`govuk_node_list` more selective about which hosts are returned.

Previously, `govuk_node_list` would match any host that included or
inherited from any of the node classes passed to it.

For example, passing a node class of 'base' would return all hosts,
since all node classes inherit from the `govuk::node::s_base` class.

Instead, make `govuk_node_list` match the supplied node classes to the
machines' hostnames, as we do already in the `govuk_node_class` function
that Puppet uses to determine which node class a machine belongs to:
https://github.gds/gds/puppet/blob/0d22ff0c/modules/govuk/lib/puppet/parser/functions/govuk_node_class.rb#L37-L39

Aside from making `govuk_node_list` more consistent with
`govuk_node_class`, this change also fixes an issue for the new draft
machines [1][2][3] whereby `govuk_node_list` would inadvertently match
more machines than expected because the new draft node classes included
the node classes of their published counterparts.

Note that we now raise an error if the supplied node classes contain a
hyphen; this is to prevent `govuk_node_list` from accepting both hyphens
and underscores.

Node classes should use underscores only, which is how they are referred
to in the `gds/alphagov-deployment` Capistrano scripts when we specify
the `server_class` that indicates which machines an application should
be deployed to.

Difference when searching for the `base` node class:

    mattbostock@preview-puppetmaster-1:~$ govuk_node_list -c base | wc -l
    97
    mattbostock@preview-puppetmaster-1:~$ ./test3.py -c base | wc -l
    0

Difference when searching for the `draft_frontend` node class:

    mattbostock@preview-puppetmaster-1:~$ govuk_node_list -c draft_frontend
    draft-frontend-1.frontend.production
    draft-frontend-2.frontend.production
    frontend-1.frontend.production
    frontend-2.frontend.production
    mattbostock@preview-puppetmaster-1:~$ ./test3.py -c draft_frontend
    draft-frontend-1.frontend.production
    draft-frontend-2.frontend.production
    mattbostock@preview-puppetmaster-1:~$

Difference when incorrectly passing a node class containing a hyphen:

    mattbostock@preview-puppetmaster-1:~$ govuk_node_list -c postgresql-primary
    mattbostock@preview-puppetmaster-1:~$ echo $?
    0
    mattbostock@preview-puppetmaster-1:~$ ./test3.py -c postgresql-primary
    Usage: test3.py [options]

    test3.py: error: Node classes should not use hyphens. Hint: Try an underscore
    mattbostock@preview-puppetmaster-1:~$ echo $?
    2

[1]: https://github.gds/gds/puppet/blob/0d22ff0cccd3aaf24a63aa0ca1abaaccca1dfd0e/modules/govuk/manifests/node/s_draft_cache.pp#L16
[2]: https://github.gds/gds/puppet/blob/0d22ff0cccd3aaf24a63aa0ca1abaaccca1dfd0e/modules/govuk/manifests/node/s_draft_cache.pp#L16
[3]: https://github.gds/gds/puppet/blob/0d22ff0cccd3aaf24a63aa0ca1abaaccca1dfd0e/modules/govuk/manifests/node/s_draft_content_store.pp#L3

alphagov/govuk-puppet,alphagov/govuk-puppet,alphagov/govuk-puppet,alphagov/govuk-puppet,alphagov/govuk-puppet,alphagov/govuk-puppet