2019-01-03 14:34:37 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Create image directory
|
|
|
|
file:
|
|
|
|
state: directory
|
2019-04-24 20:34:46 +00:00
|
|
|
path: "{{ images_dir }}"
|
2019-01-03 14:34:37 +00:00
|
|
|
|
|
|
|
- name: Download images files
|
|
|
|
get_url:
|
|
|
|
url: "{{ item.value.url }}"
|
|
|
|
dest: "{{ images_dir }}/{{ item.value.filename }}"
|
|
|
|
checksum: "{{ item.value.checksum }}"
|
|
|
|
with_dict:
|
|
|
|
- "{{ images }}"
|
|
|
|
|
2020-07-10 08:07:48 +00:00
|
|
|
- name: Unxz compressed images
|
|
|
|
command: unxz --force {{ images_dir }}/{{ item.value.filename }}
|
|
|
|
with_dict:
|
|
|
|
- "{{ images }}"
|
|
|
|
when:
|
|
|
|
- item.value.filename.endswith('.xz')
|
|
|
|
|
2019-01-03 14:34:37 +00:00
|
|
|
- name: Convert images which is not in qcow2 format
|
2020-07-10 08:07:48 +00:00
|
|
|
command: qemu-img convert -O qcow2 {{ images_dir }}/{{ item.value.filename.rstrip('.xz') }} {{ images_dir }}/{{ item.key }}.qcow2
|
2019-01-03 14:34:37 +00:00
|
|
|
with_dict:
|
|
|
|
- "{{ images }}"
|
|
|
|
when:
|
2019-04-17 15:42:03 +00:00
|
|
|
- not (item.value.converted|bool)
|
2019-01-03 14:34:37 +00:00
|
|
|
|
|
|
|
- name: Make sure all images are ending with qcow2
|
2020-07-10 08:07:48 +00:00
|
|
|
command: cp {{ images_dir }}/{{ item.value.filename.rstrip('.xz') }} {{ images_dir }}/{{ item.key }}.qcow2
|
2019-01-03 14:34:37 +00:00
|
|
|
with_dict:
|
|
|
|
- "{{ images }}"
|
|
|
|
when:
|
2019-04-17 15:42:03 +00:00
|
|
|
- item.value.converted|bool
|
2019-01-03 14:34:37 +00:00
|
|
|
|
2020-07-27 13:24:17 +00:00
|
|
|
- name: Resize images # noqa 301
|
2019-01-03 14:34:37 +00:00
|
|
|
command: qemu-img resize {{ images_dir }}/{{ item.key }}.qcow2 +8G
|
|
|
|
with_dict:
|
|
|
|
- "{{ images }}"
|
|
|
|
|
|
|
|
# STEP 2: Include the images inside a container
|
|
|
|
- name: Template default Dockerfile
|
|
|
|
template:
|
|
|
|
src: Dockerfile
|
|
|
|
dest: "{{ images_dir }}/Dockerfile"
|
|
|
|
|
2020-07-27 13:24:17 +00:00
|
|
|
- name: Create docker images for each OS # noqa 301
|
2019-05-02 21:24:21 +00:00
|
|
|
command: docker build -t {{ registry }}/vm-{{ item.key }} --build-arg cloud_image="{{ item.key }}.qcow2" {{ images_dir }}
|
2019-01-03 14:34:37 +00:00
|
|
|
with_dict:
|
|
|
|
- "{{ images }}"
|
|
|
|
|
2020-07-27 13:24:17 +00:00
|
|
|
- name: docker login # noqa 301
|
2019-01-03 14:34:37 +00:00
|
|
|
command: docker login -u="{{ docker_user }}" -p="{{ docker_password }}" "{{ docker_host }}"
|
|
|
|
|
2020-07-27 13:24:17 +00:00
|
|
|
- name: docker push image # noqa 301
|
2019-01-03 14:34:37 +00:00
|
|
|
command: docker push {{ registry }}/vm-{{ item.key }}:latest
|
|
|
|
with_dict:
|
|
|
|
- "{{ images }}"
|