ansible ad-hoc commands do almost exactly what you do but in a more scalable fashion
https://docs.ansible.com/ansible/latest/user_guide/intro_adh...