I am setting up a kubernetes setup using ansible. To setup master i have written a playbook as shown below.

```
- hosts: master
  become: yes
  tasks:
    - name: initialize the cluster
      shell: kubeadm init --pod-network-cidr=10.244.0.0/16 

    - name: create .kube directory
      become: yes
      become_user: ubuntu
      file:
        path: $HOME/.kube
        state: directory
        mode: 0755

    - name: copy admin.conf to user's kube config
      copy:
        src: /etc/kubernetes/admin.conf
        dest: /home/ubuntu/.kube/config
        remote_src: yes
        owner: ubuntu

    - name: install Pod network
      become: yes
      become_user: ubuntu
      shell: kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.yml >> pod_network_setup.txt
      args:
        chdir: $HOME
        creates: pod_network_setup.txt

```

The problem is that when i run the playbook, it doesn't wait for the initialization to complete i.e. for command "kubeadm init " to return and runs each task one after another. Since, the initialization takes time and one it is completed then only the file "/etc/kubernetes/admin.conf" is created. As ansible doesn't wait for it to complete it exists giving error in task 3 that "/etc/kubernetes/admin.conf" is not found.

If i run following playbook then ansible waits till the initialization is complete i.e. the control hangs till "kubeadm init " returns.

```
- hosts: master
  become: yes
  tasks:
    - name: initialize the cluster
      shell: kubeadm init --pod-network-cidr=10.244.0.0/16 

```

How can i make ansible wait for command "kubeadm init " to complete and then only start another command ?