Ansible get_url with regex to fetch the latest github release from a repo
Ansible get_url with regex to fetch the latest github release from a repo
November 23, 2025
This is the best I’ve come up with so far to get_url within Ansible to fetch the latest release from a Github repository. To customize to your needs, change the url portion to point to your desired repo (this one points to Duplicacy) and then adjust the “linux_x64” to a substring from the release files to narrow down what file you want.
# set export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES so it doesn't crash on mac
- name: Download archive if newer
ansible.builtin.get_url:
url: "{{ lookup('url', 'https://api.github.com/repos/gilbertchen/duplicacy/releases/latest', split_lines=false) | regex_search('browser_download_url.*(?=.*linux_x64.*)\"(.*?)\"', '\\1') | first | trim }}"
dest: "{{ download_path }}"
mode: '0744'
register: download_statusLast updated on