---
- name: create temp directory
  action: mktemp_dir
  register: _temp

- name: download package to temp
  get_url: >
    url={{ roundcube_pkg_url }}
    dest=/tmp/ansible/{{ roundcube_pkg_url | basename }}

- name: unpack package in temp
  unarchive: >
    copy=no
    src={{ _temp.path }}/{{ roundcube_pkg_url | basename }}
    dest={{ _temp.path }}

- name: remove useless files and directories
  file: >
    state=absent
    path={{ _temp.path }}/{{ roundcube_pkg_url | basename | replace('.tar.gz', '') }}/{{ item }}
  with_items:
    - .htaccess
    - composer.json-dist
    - README.md
    - installer
    - logs
    - temp
    - config/config.inc.php.sample
  tags: cleanup

- name: copy files to place
  shell: >
    cp -r {{ _temp.path }}/{{ roundcube_pkg_url | basename | replace('.tar.gz', '') }}/* {{ roundcube_www_dir }}/

- name: create .version file
  copy: >
    content={{ roundcube_version }}
    dest={{ roundcube_base_dir }}/.version
    owner=root group=root mode=0644

- name: delete temp directory
  file: >
    state=absent
    path={{ _temp.path }}
  tags: cleanup

---
- name: create temp directory
  action: mktemp_dir
  register: _temp

- name: download package to temp
  get_url: >
    url={{ roundcube_pkg_url }}
    dest={{ _temp.path }}/{{ roundcube_pkg_url | basename }}

- name: unpack package in temp
  unarchive: >
    copy=no
    src={{ _temp.path }}/{{ roundcube_pkg_url | basename }}
    dest={{ _temp.path }}

- name: remove useless files and directories
  file: >
    state=absent
    path={{ _temp.path }}/{{ roundcube_pkg_url | basename | replace('.tar.gz', '') }}/{{ item }}
  with_items:
    - .htaccess
    - composer.json-dist
    - README.md
    - installer
    - logs
    - temp
    - config/config.inc.php.sample
  tags: cleanup

- name: copy files to place
  shell: >
    cp -r {{ _temp.path }}/{{ roundcube_pkg_url | basename | replace('.tar.gz', '') }}/* {{ roundcube_www_dir }}/

- name: create .version file
  copy: >
    content={{ roundcube_version }}
    dest={{ roundcube_base_dir }}/.version
    owner=root group=root mode=0644

- name: delete temp directory
  file: >
    state=absent
    path={{ _temp.path }}
  tags: cleanup

Fix incorrect temp path for download
Fix incorrect temp path for download
