我在Nexus服务器上有一堆文件,并且可以通过Web浏览器使用REST服务浏览原始存储库。
该站点上的zip文件不是静态的,并且可能具有随机名称。
我已经尝试过unarchive
和get_url
模块,但只有在我知道远程文件名的情况下它们才起作用。
我现在唯一的选择是使用command
模块并使用curl或wget下载文件。
wget -r -np -l 1 -A zip \
http://localhost:8081/service/rest/repository/browse/repo/installs/latest/
是否有使用Ansible模块实现此目标的更好方法?
谢谢
答案 0 :(得分:1)
是否有使用Ansible模块实现此目标的更好方法?
- uri:
url: http://localhost:8081/service/rest/repository/browse/repo/installs/latest/
return_content: yes
register: the_files
- debug: var=the_zips
vars:
the_zips: >-
{{ the_files.content | regex_findall("\w+\.zip") }}
将是我的猜测,但这实际上取决于我们在讨论这些文件名时到底有多“随机”。