Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible: Install tarball via HTTP

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?

like image 581
Simon Avatar asked Nov 12 '14 10:11

Simon


People also ask

What is the most efficient way to install Ansible's new version?

For other installation options, we recommend installing via “pip”, which is the Python package manager, though other options are also available. If you wish to track the development release to use and test the latest features, we will share information about running from source.


2 Answers

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

like image 51
Kosy Anyanwu Avatar answered Sep 23 '22 19:09

Kosy Anyanwu


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.

like image 31
leucos Avatar answered Sep 23 '22 19:09

leucos