I use CFengine for automation of different taks like copying config files from one place to nodes, reloading services after this, etc. And recently i configured it to check and install packages for different boxes depending on their role. More here
Now cfengine should install packages if box is either ubuntu or debian and class nodes is defined. But there’s one little problem: if you copy config file for some of those packages, or for some reason it resides on the box, apt-get/dpkg will ask you what to do with old/new config (use old or install new version).