---
- name: "Which nodes have the build"
  build_cache_manager:
      action: check_cache_exists
      cache_directory: "{{ cache_directory }}"
      build: "{{ build }}"
  register: cache_exists

- name: "Ensure cache directory exists"
  file:
    path: "{{ cache_directory }}/{{ build }}"
    state: directory
    mode: 0755

- name: "Get every node the build"
  command: "scp {{ cache_directory }}/{{ build }}/{{ tarball_filename }} @{{ inventory_hostname }}:{{cache_directory}}/{{ build }}/{{ tarball_filename }}.tmp"
  delegate_to: localhost
  when: not cache_exists.message

- name: "Rename build_file"
  command: "mv {{ cache_directory }}/{{ build }}/{{ tarball_filename }}.tmp {{cache_directory}}/{{ build }}/{{ tarball_filename }}"
  when: not cache_exists.message
