--- - hosts: all become: true tasks: - include_tasks: common.yml - name: Initialize the Kubernetes cluster using kubeadm command: kubeadm init --apiserver-advertise-address="{{ node_ip }}" --apiserver-cert-extra-sans="{{ node_ip }}" --node-name k8s-master --pod-network-cidr=192.168.0.0/16 - name: Setup kubeconfig for vagrant user command: "{{ item }}" with_items: - mkdir -p /home/vagrant/.kube - cp -i /etc/kubernetes/admin.conf /home/vagrant/.kube/config - chown vagrant:vagrant /home/vagrant/.kube/config - name: Install calico pod network become: false command: "kubectl create -f https://docs.projectcalico.org/manifests/calico-typha.yaml" - name: Generate join command command: "kubeadm token create --print-join-command" register: join_command - name: Copy join command to local file local_action: copy content="{{ join_command.stdout_lines[0] }}" dest="./join-command" handlers: - name: docker status service: name: docker state: started