download switch boot images from dropbox

Change-Id: I4eddf48b4b30106ad832195cbe3c1323b7c788d1
(cherry picked from commit 338727760ed5f403e05558a07affef3cf730d309)
diff --git a/roles/maas/tasks/download.yml b/roles/maas/tasks/download.yml
new file mode 100644
index 0000000..d5b2243
--- /dev/null
+++ b/roles/maas/tasks/download.yml
@@ -0,0 +1,35 @@
+---
+# For some reason the ansible get_url retrieves HTML when we attempt to download the switch
+# boot resources from drop box, but using curl things work. So this include is all about
+# downloading the boot resource assuming it is not already on the local files (as detetermined
+# by the file size in bytes)
+
+- name: Get Remote Size
+  shell: curl -sSL -I "{{ item.url }}" | grep Content-Length | tail -1 | cut "-d " -f2
+  register: remote_size
+  tags:
+    - switch_support
+
+- name: Check Local File
+  stat:
+    path: "/var/www/html/{{ item.dest }}"
+  register: local_size
+  tags:
+    - switch_support
+
+- name: Download Switch Boot Resource
+  become: yes
+  command: curl -sSL "{{ item.url }}" -o "/var/www/html/{{ item.dest }}"
+  when: local_size.stat.exists == false or remote_size.stdout|int != local_size.stat.size
+  tags:
+    - switch_support
+
+- name: Switch Boot Resources Permissions
+  become: yes
+  file:
+    path: "/var/www/html/{{ item.dest }}"
+    owner: root
+    group: root
+    mode: 0644
+  tags:
+    - switch_support
diff --git a/roles/maas/tasks/main.yml b/roles/maas/tasks/main.yml
index d247b4a..7b9089e 100644
--- a/roles/maas/tasks/main.yml
+++ b/roles/maas/tasks/main.yml
@@ -144,17 +144,8 @@
   changed_when: false
   failed_when: mgmt_ip_address.rc != 0 or mgmt_ip_address.stdout == ""
 
-# Currently the onie image is being stored in **Dropbox** on a personal account, which is not really what we want to
-# have in production, but it works for the time being.
-- name: Switch Boot Resources
-  become: yes
-  get_url:
-    url={{ item.url }}
-    dest=/var/www/html/{{ item.dest }}
-    owner=root
-    group=root
-    mode=0644
-    validate_certs=no
+- name: Switch Resource
+  include: download.yml
   with_items:
     - { url : "{{ accton_as6712_32x }}", dest : "onie-installer-x86_64-accton_as6712_32x-r0" }
     - { url : "{{ accton_as5712_54x }}", dest : "onie-installer-x86_64-accton_as5712_54x-r0" }
diff --git a/roles/maas/vars/main.yml b/roles/maas/vars/main.yml
index b2ac1d3..7d2f69f 100644
--- a/roles/maas/vars/main.yml
+++ b/roles/maas/vars/main.yml
@@ -1,5 +1,5 @@
-accton_as5712_54x: 'http://178.33.61.6/putstorage/DownloadFileHash/AA90EC2D3A5A4A5QQWE3332069EWQS/onie-installer-x86_64-accton_as6712_32x-r0'
-accton_as6712_32x: 'http://178.33.61.6/putstorage/DownloadFileHash/AA90EC2D3A5A4A5QQWE3332069EWQS/onie-installer-x86_64-accton_as6712_32x-r0'
+accton_as5712_54x: 'https://www.dropbox.com/s/tgpsmblubr6r0xc/onie-installer-x86_64-accton_as6712_32x-r0'
+accton_as6712_32x: 'https://www.dropbox.com/s/tgpsmblubr6r0xc/onie-installer-x86_64-accton_as6712_32x-r0'
 
 virtualbox:
     # CHANGE: