You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.5 KiB

  1. ---
  2. - name: file_download | Downloading...
  3. debug:
  4. msg:
  5. - "URL: {{ download.url }}"
  6. - "Dest: {{ download.dest }}"
  7. - name: file_download | Create dest directory
  8. file:
  9. path: "{{ download.dest | dirname }}"
  10. state: directory
  11. recurse: yes
  12. when:
  13. - download.enabled
  14. - download.file
  15. - group_names | intersect(download.groups) | length
  16. # As in 'download_container.yml':
  17. # In Ansible 2.4 omitting download delegate is broken. Move back
  18. # to one task in the future.
  19. - name: file_download | Download item (delegate)
  20. get_url:
  21. url: "{{ download.url }}"
  22. dest: "{{ download.dest }}"
  23. sha256sum: "{{ download.sha256|default(omit) }}"
  24. owner: "{{ download.owner|default(omit) }}"
  25. mode: "{{ download.mode|default(omit) }}"
  26. validate_certs: "{{ download_validate_certs }}"
  27. url_username: "{{ download.username|default(omit) }}"
  28. url_password: "{{ download.password|default(omit) }}"
  29. force_basic_auth: "{{ download.force_basic_auth|default(omit) }}"
  30. register: get_url_result
  31. until: "'OK' in get_url_result.msg or 'file already exists' in get_url_result.msg"
  32. retries: 4
  33. delay: "{{ retry_stagger | default(5) }}"
  34. delegate_to: "{{ download_delegate }}"
  35. when:
  36. - download_run_once
  37. - download.enabled
  38. - download.file
  39. - group_names | intersect(download.groups) | length
  40. run_once: yes
  41. - name: file_download | Download item (all)
  42. get_url:
  43. url: "{{ download.url }}"
  44. dest: "{{ download.dest }}"
  45. sha256sum: "{{ download.sha256|default(omit) }}"
  46. owner: "{{ download.owner|default(omit) }}"
  47. mode: "{{ download.mode|default(omit) }}"
  48. validate_certs: "{{ download_validate_certs }}"
  49. url_username: "{{ download.username|default(omit) }}"
  50. url_password: "{{ download.password|default(omit) }}"
  51. force_basic_auth: "{{ download.force_basic_auth|default(omit) }}"
  52. register: get_url_result
  53. until: "'OK' in get_url_result.msg or 'file already exists' in get_url_result.msg"
  54. retries: 4
  55. delay: "{{ retry_stagger | default(5) }}"
  56. when:
  57. - not download_run_once
  58. - download.enabled
  59. - download.file
  60. - group_names | intersect(download.groups) | length
  61. - name: file_download | Extract archives
  62. unarchive:
  63. src: "{{ download.dest }}"
  64. dest: "{{ download.dest |dirname }}"
  65. owner: "{{ download.owner|default(omit) }}"
  66. mode: "{{ download.mode|default(omit) }}"
  67. copy: no
  68. when:
  69. - download.enabled
  70. - download.file
  71. - download.unarchive|default(False)
  72. - group_names | intersect(download.groups) | length