SSH is defninitely not less secure than HTTPS if done right. And it has
the advantage that it's typically already there.
However, the Ansible connection mechanism is pluggable and you might want
to have a look at the connection plugins documentation at
https://docs.ansible.com/ansible/latest/plugins/connection.html
if there's something that fit's your needs. I strongly advise against
trying to write your own connection plugin unless you are a security
expert and know what you are doing.
Cheers
-Andi