---
- name: create kubernetes config directory
  file: path={{ kube_config_dir }} state=directory

- name: create kubernetes script directory
  file: path={{ kube_script_dir }} state=directory

- name: Make sure manifest directory exists
  file: path={{ kube_manifest_dir }} state=directory


- name: certs | create system kube-cert groups
  group: name={{ kube_cert_group }} state=present system=yes

- name: create system kube user
  user:
    name=kube
    comment="Kubernetes user"
    shell=/sbin/nologin
    state=present
    system=yes
    groups={{ kube_cert_group }}

- include: install.yml

- include: secrets.yml
  tags:
    - secrets

- name: Write kubelet config file
  template: src=kubelet.j2 dest={{ kube_config_dir }}/kubelet.conf backup=yes
  notify:
    - restart kubelet

- name: write the kubecfg (auth) file for kubelet
  template: src=node-kubeconfig.yaml.j2 dest={{ kube_config_dir }}/node-kubeconfig.yaml backup=yes
  notify:
    - restart kubelet

- name: Write proxy manifest
  template: 
    src: manifests/kube-proxy.manifest.j2
    dest: "{{ kube_manifest_dir }}/kube-proxy.manifest"

- name: Write network-environment
  template: src=network-environment.j2 dest=/etc/network-environment mode=640

- name: Enable kubelet
  service:
    name: kubelet
    enabled: yes
    state: started
