Reputation: 12508
I'd like to extend my ansible playbook to install/verify installation of phantomjs and wkhtmltopdf to my Debian 7 machine. Both programs are available as packed tarballs via HTTP. I know the get_url module, but it doesn't unpack stuff, and if I'd add some shell commands for unpacking and moving the binaries, I suspect each time I run ansible, the tarballs would be downloaded, unpacked and moved again, causing unnecessary network traffic.
How can I solve this? Should I make a .deb file and run that using the apt command, or should I make a new ansible module for installing tarballs, or is there something that I'm overlooking?
Upvotes: 12
Views: 15753
Reputation: 347
You can also use the unarchive module to unpack your tar file directly from the HTTP source.
- name: Download and unpack directly from HTTP source
unarchive:
src: "http://your_tarball_to_download.tar.gz"
dest: "/home/dest_directory"
copy: no
More information about the unarchive module can be found on the docs http://docs.ansible.com/ansible/unarchive_module.html
Upvotes: 3
Reputation: 18279
If you download specific versions (e.g. foo_1.2.3.tar.gz
and not foo_latest.tar.gz
), you can do this by keeping the downloaded tarball :
- name: Gets tarball
sudo: yes
sudo_user: "{{ deploy_user }}"
get_url:
url="http://some.host/some_tarball-{{ tarball_version }}.tar.gz"
dest="/home/{{ deploy_user }}/"
register: new_archive
- name: Unarchive source
sudo: yes
sudo_user: "{{ deploy_user }}"
unarchive:
src="/home/{{ deploy_user }}/some_tarball-{{ tarball_version }}.tar.gz"
dest="/home/{{ deploy_user }}/app/"
copy=no
when: new_archive|changed
Change variables according to your environment.
Upvotes: 12