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.

59 lines
1.7 KiB

  1. ---
  2. - name: Create image directory
  3. file:
  4. state: directory
  5. path: "{{ images_dir }}"
  6. - name: Download images files
  7. get_url:
  8. url: "{{ item.value.url }}"
  9. dest: "{{ images_dir }}/{{ item.value.filename }}"
  10. checksum: "{{ item.value.checksum }}"
  11. with_dict:
  12. - "{{ images }}"
  13. - name: Unxz compressed images
  14. command: unxz --force {{ images_dir }}/{{ item.value.filename }}
  15. with_dict:
  16. - "{{ images }}"
  17. when:
  18. - item.value.filename.endswith('.xz')
  19. - name: Convert images which is not in qcow2 format
  20. command: qemu-img convert -O qcow2 {{ images_dir }}/{{ item.value.filename.rstrip('.xz') }} {{ images_dir }}/{{ item.key }}.qcow2
  21. with_dict:
  22. - "{{ images }}"
  23. when:
  24. - not (item.value.converted|bool)
  25. - name: Make sure all images are ending with qcow2
  26. command: cp {{ images_dir }}/{{ item.value.filename.rstrip('.xz') }} {{ images_dir }}/{{ item.key }}.qcow2
  27. with_dict:
  28. - "{{ images }}"
  29. when:
  30. - item.value.converted|bool
  31. - name: Resize images # noqa 301
  32. command: qemu-img resize {{ images_dir }}/{{ item.key }}.qcow2 +8G
  33. with_dict:
  34. - "{{ images }}"
  35. # STEP 2: Include the images inside a container
  36. - name: Template default Dockerfile
  37. template:
  38. src: Dockerfile
  39. dest: "{{ images_dir }}/Dockerfile"
  40. - name: Create docker images for each OS # noqa 301
  41. command: docker build -t {{ registry }}/vm-{{ item.key }} --build-arg cloud_image="{{ item.key }}.qcow2" {{ images_dir }}
  42. with_dict:
  43. - "{{ images }}"
  44. - name: docker login # noqa 301
  45. command: docker login -u="{{ docker_user }}" -p="{{ docker_password }}" "{{ docker_host }}"
  46. - name: docker push image # noqa 301
  47. command: docker push {{ registry }}/vm-{{ item.key }}:latest
  48. with_dict:
  49. - "{{ images }}"