If you are converting your roles into a collection, and have to keep
supporting the old roles format for the foreseeable future, and want to
change your Ansible YAML files into collections format such that they
match the roles format as closely as possible, you might be interested
in
https://linux-system-roles.github.io/2020/09/collection-conversion-ruamel-roundtrip
in which we use some techniques from ansible-lint and ruamel.