Puppet isn't an orchestration framework, it is configuration management. While you can execute commands (exec), you generally don't want to execute commands on other instances, you want to describe the endstate. When you have the end state described in the puppet DSL, the master uses information from each of your nodes to build a catalog, and that catalog is applied to your nodes.
In your example, you can't tell puppet to 'restart X service on all the nodes that have it', you would tell puppet that the contents of a file should be X, and if they change, that file can notify the service. If a service gets notified, it will be restarted (to pick up the changes in the file).
If you are looking for running commands on your instances, PE has Application Orchestration, but until then their MCollective tool allows you to search for instances based on facter facts, or installed classes, and it allows you to tell those nodes to run commands, and it will return pass/fail information to you.
For a great discussion of thinking declaratively, see Ben Ford's blogpost - http://www.binford2k.com/content/2014...
Hope that helps!