---
- name: Get Systemd unit files from Kubernetes repository
  get_url:
    url=https://raw.githubusercontent.com/kubernetes/contrib/master/init/systemd/{{ item }}.service
    dest=/etc/systemd/system/{{ item }}.service
    force=yes
  register: "{{ item }}_service"
  notify:
    - reload systemd
  with_items:
    - kube-apiserver
    - kube-controller-manager
    - kube-scheduler
    - kubelet
  environment:
    http_proxy: "{{ http_proxy|default('') }}"
    https_proxy: "{{ https_proxy|default('') }}"
    no_proxy: "{{ no_proxy|default('') }}"

- name: Get Systemd config files from Kubernetes repository
  get_url:
    url=https://raw.githubusercontent.com/kubernetes/contrib/master/init/systemd/environ/{{ item }}
    dest={{ kube_config_dir }}/{{ item }}
    force=yes
  register: "{{ item }}_default"
  notify:
    - reload systemd
  with_items:
    - apiserver
    - config
    - scheduler
    - controller-manager
    - kubelet
  environment:
    http_proxy: "{{ http_proxy|default('') }}"
    https_proxy: "{{ https_proxy|default('') }}"
    no_proxy: "{{ no_proxy|default('') }}"

- name: Get Systemd tmpfile from Kubernetes repository
  get_url:
    url=https://raw.githubusercontent.com/kubernetes/contrib/master/init/systemd/tmpfiles.d/kubernetes.conf
    dest=/usr/lib/tmpfiles.d/kubernetes.conf
    force=yes
  notify:
    - reload systemd
  environment:
    http_proxy: "{{ http_proxy|default('') }}"
    https_proxy: "{{ https_proxy|default('') }}"
    no_proxy: "{{ no_proxy|default('') }}"

