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.

53 lines
1.5 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: Convert images which is not in qcow2 format
  14. command: qemu-img convert -O qcow2 {{ images_dir }}/{{ item.value.filename }} {{ images_dir }}/{{ item.key }}.qcow2
  15. with_dict:
  16. - "{{ images }}"
  17. when:
  18. - item.value.converted|bool != true
  19. register: converted
  20. - name: Make sure all images are ending with qcow2
  21. command: cp {{ images_dir }}/{{ item.value.filename }} {{ images_dir }}/{{ item.key }}.qcow2
  22. with_dict:
  23. - "{{ images }}"
  24. when:
  25. - item.value.converted|bool == true
  26. - name: Resize images
  27. command: qemu-img resize {{ images_dir }}/{{ item.key }}.qcow2 +8G
  28. with_dict:
  29. - "{{ images }}"
  30. # STEP 2: Include the images inside a container
  31. - name: Template default Dockerfile
  32. template:
  33. src: Dockerfile
  34. dest: "{{ images_dir }}/Dockerfile"
  35. - name: Create docker images for each OS
  36. command: docker build -t {{registry}}/vm-{{ item.key }} --build-arg cloud_image="{{ item.key }}.qcow2" {{ images_dir }}
  37. with_dict:
  38. - "{{ images }}"
  39. - name: docker login
  40. command: docker login -u="{{ docker_user }}" -p="{{ docker_password }}" "{{ docker_host }}"
  41. - name: docker push image
  42. command: docker push {{ registry }}/vm-{{ item.key }}:latest
  43. with_dict:
  44. - "{{ images }}"