Replace deprecated 'with_dict' with 'loop' (#7442)
(cherry picked from commit 6479e26904
)
This commit is contained in:
parent
16c750b20a
commit
5cf0de61a3
3 changed files with 10 additions and 17 deletions
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
- name: download | Download files / images
|
- name: download | Download files / images
|
||||||
include_tasks: "{{ include_file }}"
|
include_tasks: "{{ include_file }}"
|
||||||
with_dict: "{{ downloads | combine(kubeadm_images) }}"
|
loop: "{{ downloads | combine(kubeadm_images) | dict2items }}"
|
||||||
vars:
|
vars:
|
||||||
download: "{{ download_defaults | combine(item.value) }}"
|
download: "{{ download_defaults | combine(item.value) }}"
|
||||||
include_file: "download_{% if download.container %}container{% else %}file{% endif %}.yml"
|
include_file: "download_{% if download.container %}container{% else %}file{% endif %}.yml"
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
etc_hosts_localhosts_dict_target: >-
|
etc_hosts_localhosts_dict_target: >-
|
||||||
{%- set target_entries = (etc_hosts_localhosts_dict|default({})).get(item.key, []) | difference(item.value.get('unexpected' ,[])) -%}
|
{%- set target_entries = (etc_hosts_localhosts_dict|default({})).get(item.key, []) | difference(item.value.get('unexpected' ,[])) -%}
|
||||||
{{ etc_hosts_localhosts_dict_target|default({}) | combine({item.key: (target_entries + item.value.expected)|unique}) }}
|
{{ etc_hosts_localhosts_dict_target|default({}) | combine({item.key: (target_entries + item.value.expected)|unique}) }}
|
||||||
with_dict: "{{ etc_hosts_localhost_entries }}"
|
loop: "{{ etc_hosts_localhost_entries|dict2items }}"
|
||||||
|
|
||||||
- name: Hosts | Update (if necessary) hosts file
|
- name: Hosts | Update (if necessary) hosts file
|
||||||
lineinfile:
|
lineinfile:
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
state: present
|
state: present
|
||||||
backup: yes
|
backup: yes
|
||||||
unsafe_writes: yes
|
unsafe_writes: yes
|
||||||
with_dict: "{{ etc_hosts_localhosts_dict_target }}"
|
loop: "{{ etc_hosts_localhosts_dict_target|dict2items }}"
|
||||||
|
|
||||||
# gather facts to update ansible_fqdn
|
# gather facts to update ansible_fqdn
|
||||||
- name: Update facts
|
- name: Update facts
|
||||||
|
|
|
@ -10,34 +10,29 @@
|
||||||
url: "{{ item.value.url }}"
|
url: "{{ item.value.url }}"
|
||||||
dest: "{{ images_dir }}/{{ item.value.filename }}"
|
dest: "{{ images_dir }}/{{ item.value.filename }}"
|
||||||
checksum: "{{ item.value.checksum }}"
|
checksum: "{{ item.value.checksum }}"
|
||||||
with_dict:
|
loop: "{{ images|dict2items }}"
|
||||||
- "{{ images }}"
|
|
||||||
|
|
||||||
- name: Unxz compressed images
|
- name: Unxz compressed images
|
||||||
command: unxz --force {{ images_dir }}/{{ item.value.filename }}
|
command: unxz --force {{ images_dir }}/{{ item.value.filename }}
|
||||||
with_dict:
|
loop: "{{ images|dict2items }}"
|
||||||
- "{{ images }}"
|
|
||||||
when:
|
when:
|
||||||
- item.value.filename.endswith('.xz')
|
- item.value.filename.endswith('.xz')
|
||||||
|
|
||||||
- name: Convert images which is not in qcow2 format
|
- name: Convert images which is not in qcow2 format
|
||||||
command: qemu-img convert -O qcow2 {{ images_dir }}/{{ item.value.filename.rstrip('.xz') }} {{ images_dir }}/{{ item.key }}.qcow2
|
command: qemu-img convert -O qcow2 {{ images_dir }}/{{ item.value.filename.rstrip('.xz') }} {{ images_dir }}/{{ item.key }}.qcow2
|
||||||
with_dict:
|
loop: "{{ images|dict2items }}"
|
||||||
- "{{ images }}"
|
|
||||||
when:
|
when:
|
||||||
- not (item.value.converted|bool)
|
- not (item.value.converted|bool)
|
||||||
|
|
||||||
- name: Make sure all images are ending with qcow2
|
- name: Make sure all images are ending with qcow2
|
||||||
command: cp {{ images_dir }}/{{ item.value.filename.rstrip('.xz') }} {{ images_dir }}/{{ item.key }}.qcow2
|
command: cp {{ images_dir }}/{{ item.value.filename.rstrip('.xz') }} {{ images_dir }}/{{ item.key }}.qcow2
|
||||||
with_dict:
|
loop: "{{ images|dict2items }}"
|
||||||
- "{{ images }}"
|
|
||||||
when:
|
when:
|
||||||
- item.value.converted|bool
|
- item.value.converted|bool
|
||||||
|
|
||||||
- name: Resize images # noqa 301
|
- name: Resize images # noqa 301
|
||||||
command: qemu-img resize {{ images_dir }}/{{ item.key }}.qcow2 +8G
|
command: qemu-img resize {{ images_dir }}/{{ item.key }}.qcow2 +8G
|
||||||
with_dict:
|
loop: "{{ images|dict2items }}"
|
||||||
- "{{ images }}"
|
|
||||||
|
|
||||||
# STEP 2: Include the images inside a container
|
# STEP 2: Include the images inside a container
|
||||||
- name: Template default Dockerfile
|
- name: Template default Dockerfile
|
||||||
|
@ -47,16 +42,14 @@
|
||||||
|
|
||||||
- name: Create docker images for each OS # noqa 301
|
- name: Create docker images for each OS # noqa 301
|
||||||
command: docker build -t {{ registry }}/vm-{{ item.key }}:{{ item.value.tag }} --build-arg cloud_image="{{ item.key }}.qcow2" {{ images_dir }}
|
command: docker build -t {{ registry }}/vm-{{ item.key }}:{{ item.value.tag }} --build-arg cloud_image="{{ item.key }}.qcow2" {{ images_dir }}
|
||||||
with_dict:
|
loop: "{{ images|dict2items }}"
|
||||||
- "{{ images }}"
|
|
||||||
|
|
||||||
- name: docker login # noqa 301
|
- name: docker login # noqa 301
|
||||||
command: docker login -u="{{ docker_user }}" -p="{{ docker_password }}" "{{ docker_host }}"
|
command: docker login -u="{{ docker_user }}" -p="{{ docker_password }}" "{{ docker_host }}"
|
||||||
|
|
||||||
- name: docker push image # noqa 301
|
- name: docker push image # noqa 301
|
||||||
command: docker push {{ registry }}/vm-{{ item.key }}:{{ item.value.tag }}
|
command: docker push {{ registry }}/vm-{{ item.key }}:{{ item.value.tag }}
|
||||||
with_dict:
|
loop: "{{ images|dict2items }}"
|
||||||
- "{{ images }}"
|
|
||||||
|
|
||||||
- name: docker logout # noqa 301
|
- name: docker logout # noqa 301
|
||||||
command: docker logout -u="{{ docker_user }}" "{{ docker_host }}"
|
command: docker logout -u="{{ docker_user }}" "{{ docker_host }}"
|
||||||
|
|
Loading…
Reference in a new issue