Ireland stuttered on their way to beating Wales in their penultimate Six Nations game, setting up a potential championship decider with Scotland next week in Dublin.