Grouping hosts from the Ansible nmap dynamic inventory

I use the nmap inventory plugin to build an Ansible inventory of my homelab without maintaining a host list by hand. It scans a subnet and hands you every host it finds. The part that took me a while was getting those hosts into useful groups . Out of the box