- hosts: all
  tasks:
    - include_vars: container-builder-vars.yaml

    - name: "Build magnum images"
      block:
        - name: "Build {{ magnum_repository }}/{{ item.name }}:{{ item.tag }} image"
          docker_image:
            path: "{{ magnum_src_dir }}/dockerfiles/{{ item.name }}"
            name: "{{ magnum_repository }}/{{ item.name }}"
            tag: "{{ item.tag }}"
            push: no
          with_items: "{{ magnum_images }}"
          retries: 10

    - name: "Build kubernetes images v1.11"
      block:
        - name: "Build {{ magnum_repository }}/{{ item.name }}:{{ item.tag }} image"
          docker_image:
            path: "{{ magnum_src_dir }}/dockerfiles/{{ item.name }}"
            name: "{{ magnum_repository }}/{{ item.name }}"
            tag: "{{kubernetes_version_v1_11}}"
            buildargs:
              KUBE_VERSION: "{{kubernetes_version_v1_11}}"
              ADD_KUBE_ALLOW_PRIV: "true"
            push: no
          with_items: "{{ kubernetes_images }}"
          retries: 10

    - name: "Build kubernetes images v1.12"
      block:
        - name: "Build {{ magnum_repository }}/{{ item.name }}:{{ item.tag }} image"
          docker_image:
            path: "{{ magnum_src_dir }}/dockerfiles/{{ item.name }}"
            name: "{{ magnum_repository }}/{{ item.name }}"
            tag: "{{kubernetes_version_v1_12}}"
            buildargs:
              KUBE_VERSION: "{{kubernetes_version_v1_12}}"
              ADD_KUBE_ALLOW_PRIV: "true"
            push: no
          with_items: "{{ kubernetes_images }}"
          retries: 10

    - name: "Build kubernetes images v1.13"
      block:
        - name: "Build {{ magnum_repository }}/{{ item.name }}:{{ item.tag }} image"
          docker_image:
            path: "{{ magnum_src_dir }}/dockerfiles/{{ item.name }}"
            name: "{{ magnum_repository }}/{{ item.name }}"
            tag: "{{kubernetes_version_v1_13}}"
            buildargs:
              KUBE_VERSION: "{{kubernetes_version_v1_13}}"
              ADD_KUBE_ALLOW_PRIV: "true"
            push: no
          with_items: "{{ kubernetes_images }}"
          retries: 10

    - name: "Build kubernetes images v1.14"
      block:
        - name: "Build {{ magnum_repository }}/{{ item.name }}:{{ item.tag }} image"
          docker_image:
            path: "{{ magnum_src_dir }}/dockerfiles/{{ item.name }}"
            name: "{{ magnum_repository }}/{{ item.name }}"
            tag: "{{kubernetes_version_v1_14}}"
            buildargs:
              KUBE_VERSION: "{{kubernetes_version_v1_14}}"
              ADD_KUBE_ALLOW_PRIV: "true"
            push: no
          with_items: "{{ kubernetes_images }}"
          retries: 10

    - name: "Build kubernetes images v1.15"
      block:
        - name: "Build {{ magnum_repository }}/{{ item.name }}:{{ item.tag }} image"
          docker_image:
            path: "{{ magnum_src_dir }}/dockerfiles/{{ item.name }}"
            name: "{{ magnum_repository }}/{{ item.name }}"
            tag: "{{kubernetes_version_v1_15}}"
            buildargs:
              KUBE_VERSION: "{{kubernetes_version_v1_15}}"
            push: no
          with_items: "{{ kubernetes_images }}"
          retries: 10

    - name: "Build kubernetes images v1.16"
      block:
        - name: "Build {{ magnum_repository }}/{{ item.name }}:{{ item.tag }} image"
          docker_image:
            path: "{{ magnum_src_dir }}/dockerfiles/{{ item.name }}"
            name: "{{ magnum_repository }}/{{ item.name }}"
            tag: "{{kubernetes_version_v1_16}}"
            buildargs:
              KUBE_VERSION: "{{kubernetes_version_v1_16}}"
            push: no
          with_items: "{{ kubernetes_images }}"
          retries: 10

    - name: "Build helm-client image"
      block:
        - docker_image:
            path: "{{ magnum_src_dir }}/dockerfiles/helm-client"
            name: "{{ magnum_repository }}/helm-client"
            tag: "{{ helm_version }}"
            buildargs:
              HELM_VERSION: "{{ helm_version }}"
            push: no
          retries: 10