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.

93 lines
4.0 KiB

9 years ago
  1. ---
  2. - include_vars: kube_versions.yml
  3. - name: downloading...
  4. debug:
  5. msg: "{{ download.url }}"
  6. when: "{{ download.enabled|bool and not download.container|bool }}"
  7. - name: Create dest directories
  8. file: path={{local_release_dir}}/{{download.dest|dirname}} state=directory recurse=yes
  9. when: "{{ download.enabled|bool and not download.container|bool }}"
  10. delegate_to: "{{ groups['kube-master'][0] if download_run_once|bool else omit }}"
  11. run_once: "{{ download_run_once|bool }}"
  12. - name: Download items
  13. get_url:
  14. url: "{{download.url}}"
  15. dest: "{{local_release_dir}}/{{download.dest}}"
  16. sha256sum: "{{download.sha256 | default(omit)}}"
  17. owner: "{{ download.owner|default(omit) }}"
  18. mode: "{{ download.mode|default(omit) }}"
  19. register: get_url_result
  20. until: "'OK' in get_url_result.msg or 'file already exists' in get_url_result.msg"
  21. retries: 4
  22. delay: "{{ retry_stagger | random + 3 }}"
  23. when: "{{ download.enabled|bool and not download.container|bool }}"
  24. delegate_to: "{{ groups['kube-master'][0] if download_run_once|bool else omit }}"
  25. run_once: "{{ download_run_once|bool }}"
  26. - name: Extract archives
  27. unarchive:
  28. src: "{{ local_release_dir }}/{{download.dest}}"
  29. dest: "{{ local_release_dir }}/{{download.dest|dirname}}"
  30. owner: "{{ download.owner|default(omit) }}"
  31. mode: "{{ download.mode|default(omit) }}"
  32. copy: no
  33. when: "{{ download.enabled|bool and not download.container|bool and download.unarchive is defined and download.unarchive == True }}"
  34. delegate_to: "{{ groups['kube-master'][0] if download_run_once|bool else omit }}"
  35. run_once: "{{ download_run_once|bool }}"
  36. - name: Fix permissions
  37. file:
  38. state: file
  39. path: "{{local_release_dir}}/{{download.dest}}"
  40. owner: "{{ download.owner|default(omit) }}"
  41. mode: "{{ download.mode|default(omit) }}"
  42. when: "{{ download.enabled|bool and not download.container|bool and (download.unarchive is not defined or download.unarchive == False) }}"
  43. delegate_to: "{{ groups['kube-master'][0] if download_run_once|bool else omit }}"
  44. run_once: "{{ download_run_once|bool }}"
  45. - name: pulling...
  46. debug:
  47. msg: "{{ download.repo }}:{{ download.tag }}"
  48. when: "{{ download.enabled|bool and download.container|bool }}"
  49. - name: Create dest directory for saved/loaded container images
  50. file: path="{{local_release_dir}}/containers" state=directory recurse=yes
  51. when: "{{ download.enabled|bool and download.container|bool }}"
  52. #NOTE(bogdando) this brings no docker-py deps for nodes
  53. - name: Download containers
  54. command: "/usr/bin/docker pull {{ download.repo }}:{{ download.tag }}"
  55. register: pull_task_result
  56. until: pull_task_result.rc == 0
  57. retries: 4
  58. delay: "{{ retry_stagger | random + 3 }}"
  59. when: "{{ download.enabled|bool and download.container|bool }}"
  60. delegate_to: "{{ groups['kube-master'][0] if download_run_once|bool else omit }}"
  61. run_once: "{{ download_run_once|bool }}"
  62. - set_fact:
  63. fname: "{{local_release_dir}}/containers/{{download.repo|regex_replace('/|\0|:', '_')}}:{{download.tag|regex_replace('/|\0|:', '_')}}.tar"
  64. - name: Download | save container images
  65. shell: docker save "{{ download.repo }}:{{ download.tag }}" > "{{ fname }}"
  66. delegate_to: "{{groups['kube-master'][0]}}"
  67. run_once: true
  68. when: ansible_os_family != "CoreOS" and download_run_once|bool and download.enabled|bool and download.container|bool
  69. - name: Download | get container images
  70. synchronize:
  71. src: "{{ fname }}"
  72. dest: "{{local_release_dir}}/containers"
  73. mode: push
  74. register: get_task
  75. until: get_task|success
  76. retries: 4
  77. delay: "{{ retry_stagger | random + 3 }}"
  78. when: ansible_os_family != "CoreOS" and inventory_hostname != groups['kube-master'][0] and download_run_once|bool and download.enabled|bool and download.container|bool
  79. - name: Download | load container images
  80. shell: docker load < "{{ fname }}"
  81. when: ansible_os_family != "CoreOS" and inventory_hostname != groups['kube-master'][0] and download_run_once|bool and download.enabled|bool and download.container|bool