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.

114 lines
3.2 KiB

  1. ---
  2. - set_fact:
  3. fname: "{{local_release_dir}}/containers/{{download.repo|regex_replace('/|\0|:', '_')}}:{{download.tag|default(download.sha256)|regex_replace('/|\0|:', '_')}}.tar"
  4. run_once: true
  5. when:
  6. - download.enabled
  7. - download.container
  8. - download_run_once
  9. tags:
  10. - facts
  11. - name: "container_download | Set default value for 'container_changed' to false"
  12. set_fact:
  13. container_changed: "{{pull_required|default(false)}}"
  14. when:
  15. - download.enabled
  16. - download.container
  17. - download_run_once
  18. - name: "container_download | Update the 'container_changed' fact"
  19. set_fact:
  20. container_changed: "{{ pull_required|default(false) or not 'up to date' in pull_task_result.stdout }}"
  21. when:
  22. - download.enabled
  23. - download.container
  24. - download_run_once
  25. - pull_required|default(download_always_pull)
  26. run_once: "{{ download_run_once }}"
  27. tags:
  28. - facts
  29. - name: container_download | Stat saved container image
  30. stat:
  31. path: "{{fname}}"
  32. register: img
  33. changed_when: false
  34. delegate_to: "{{ download_delegate }}"
  35. delegate_facts: no
  36. become: false
  37. run_once: true
  38. when:
  39. - download.enabled
  40. - download.container
  41. - download_run_once
  42. tags:
  43. - facts
  44. - name: container_download | save container images
  45. shell: "{{ docker_bin_dir }}/docker save {{ pull_args }} | gzip -{{ download_compress }} > {{ fname }}"
  46. delegate_to: "{{ download_delegate }}"
  47. delegate_facts: no
  48. register: saved
  49. run_once: true
  50. when:
  51. - download.enabled
  52. - download.container
  53. - download_run_once
  54. - (ansible_os_family not in ["CoreOS", "Container Linux by CoreOS"] or download_delegate == "localhost")
  55. - (container_changed or not img.stat.exists)
  56. - name: container_download | copy container images to ansible host
  57. synchronize:
  58. src: "{{ fname }}"
  59. dest: "{{ fname }}"
  60. use_ssh_args: "{{ has_bastion | default(false) }}"
  61. mode: pull
  62. delegate_to: localhost
  63. delegate_facts: no
  64. run_once: true
  65. become: false
  66. when:
  67. - download.enabled
  68. - download.container
  69. - download_run_once
  70. - ansible_os_family not in ["CoreOS", "Container Linux by CoreOS"]
  71. - inventory_hostname == download_delegate
  72. - download_delegate != "localhost"
  73. - saved.changed
  74. - name: container_download | upload container images to nodes
  75. synchronize:
  76. src: "{{ fname }}"
  77. dest: "{{ fname }}"
  78. use_ssh_args: "{{ has_bastion | default(false) }}"
  79. mode: push
  80. delegate_to: localhost
  81. delegate_facts: no
  82. become: false
  83. register: get_task
  84. until: get_task|succeeded
  85. retries: 4
  86. delay: "{{ retry_stagger | random + 3 }}"
  87. when:
  88. - download.enabled
  89. - download.container
  90. - download_run_once
  91. - (ansible_os_family not in ["CoreOS", "Container Linux by CoreOS"] and
  92. inventory_hostname != download_delegate or
  93. download_delegate == "localhost")
  94. tags:
  95. - upload
  96. - upgrade
  97. - name: container_download | load container images
  98. shell: "{{ docker_bin_dir }}/docker load < {{ fname }}"
  99. when:
  100. - download.enabled
  101. - download.container
  102. - download_run_once
  103. - (ansible_os_family not in ["CoreOS", "Container Linux by CoreOS"] and
  104. inventory_hostname != download_delegate or download_delegate == "localhost")
  105. tags:
  106. - upload
  107. - upgrade