--- - name: Install K8S hosts: cp remote_user: prlab become: true become_user: root tasks: - name: update system apt: update_cache: yes cache_valid_time: 3600 - name: install git apt: name: git state: present - name: git clone k8s installer git: repo: https://git.prlab.io/andrewli315/k8s-install dest: /home/prlab/k8s/k8s-install - name: copy hosts file copy: src: ./hosts dest: /home/prlab/k8s/k8s-install - name: install k8s CP and helm chart shell: | ./k8s-install.sh ./hosts cp ./helm-install.sh - name: execute k8s cmd shell: | echo "$(kubeadm token create --print-join-command)" > /tmp/join.sh chmod +x /tmp/join.sh - name: copy file fetch: src: '/tmp/join.sh' dest: '/tmp/' - name: get the result hosts: localhost tasks: - name: cat shell: | cat /tmp/192.168.88.104/tmp/join.sh - name: put the join.sh hosts: nodes remote_user: prlab become: true become_user: root tasks: - name: apt update apt: update_cache: yes cache_valid_time: 3600 - name: install git apt: name: git state: present - name: git clone ansible.builtin.git: repo: https://git.prlab.io/andrewli315/k8s-install dest: /home/prlab/k8s/k8s-install - name: copy copy: src: ./hosts dest: /home/prlab/k8s/k8s-install/hosts - name: install k8s shell: | ./k8s-install.sh hosts echo "Install finish" args: chdir: /home/prlab/k8s/k8s-install - name: copy join.sh copy: src: /tmp/192.168.88.104/tmp/join.sh dest: /tmp/join.sh - name: execute shell: | sh /tmp/join.sh