Today I learned about the dpkg_selections module in ansible. It is used to mark packages as hold, install … It can be used to implement some apt mark functionalities.

Docs