yumdb search from_repo HDP-2.6-repo-1* | grep -v from_repo | grep -e . | sort > ~/pkg_to_remove_HDP-2.6-repo-1.lst && yum remove $(cat ~/pkg_to_remove_HDP-2.6-repo-1.lst | tr '\n' ' ' )
Just replace the 'HDP-2.6-repo-1' with the repository name of the version you're want to remove (ie: found /etc/yum.repos.d/ambari-hdp* files).
This method store a file in home directory with the list of packages removed, just in case you need to re-install something.
Not really safe at the end...
While this worked perfectly on client nodes, there seems to be dependencies with more recent versions and there is a risk you remove them if you don't watch carefully before hitting the "Y" key!