setup-container-network.yml 1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
- name: remove previous kubernetes configuration file
  file:
    path: "{{ kub_admin_home }}/.kube"
    state: absent

- name: create ~/.kube file
  file:
    path: "{{ kub_admin_home }}/.kube"
    state: directory

- name: copy default kubernetes configuration file to ~/.kube
  copy:
    src: /etc/kubernetes/admin.conf
    dest: "{{ kub_admin_home }}/.kube/config"
    remote_src: yes
  become: yes

- name: change ownership of ~/.kube/config
  file:
    path: "{{ kub_admin_home }}/.kube/config"
    owner: kub-admin
    group: docker
  become: yes

- name: install cni provider for pod network
  command: kubectl apply -f https://raw.githubusercontent.com/coreos/{{cni_provider}}/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-{{cni_provider}}.yml 

- name: generate the kubernetes join command
  command: kubeadm token create --print-join-command
  register: kub_join_command

- name: copy join command to local file
  local_action: copy content="{{ kub_join_command.stdout }}" dest="~/kub-join-command"