We have a three server cluster using AlwaysOn technology, and have created an Availability Group for the SSISDB catalog.
How would you change the code to only execute on the primary server?
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.
If you're talking about accessing the primary replica (and the Availability Group database on the primary replica) at all times, this is where the Availability Group Listener comes into play.
See this quote from BOL on the topic:
So instead of referencing a particular server, by using the Listener you can be pointing at the current primary replica of the AG.
Edit: As per Aaron's comment below, you may be looking for more specifics surrounding the particular catalog DB (as opposed to generic handling as above). You can find more information regarding this on the MSDN SSIS blog here. If both of these points explained in this answer do not clear up your question, please clarify what exactly you're looking to do.