What Ansible does in cases there's a conflict between OS version and some software Ansible manages?
Ansible is at its core a programming language - a meta programming language written in python compiling itself into python and shell scripts mostly. It will do whatever you program it to do. It all depends on how your roles and playbooks are written. It certainly can be done - almost anything can be done - your install roles could track dependencies on package versions or ranges, obviously those might need to be updated over the years, but you can be safe if you put the work into it.

It is probably unreasonable to plan further than the End of Life of the LTS distribution though, as you will fail to receive new security updates and that instantly invalidates the system as production ready.