I’m unable to test since download.sonatype.com is blocked by my company firewall, but I think you can just register the get_url:
task to discover what the resulting filename was. Then unarchive the variable name.
Something like:
- name: get nexus
ansible.builtin.get_url:
url: https://download.sonatype.com/nexus/3/latest-unix.tar.gz
dest: /tmp/
owner: "{{ app_name }}"
group: "{{ app_name }}"
register: nexus
- name: unpack nexus.tar
ansible.builtin.unarchive:
src: "{{ nexus.dest }}"
dest: "/opt/"
owner: "{{ app_name }}"
group: "{{ app_name }}"
remote_src: true
mode: 0700