E
E
ENigma3712021-10-06 17:43:00
Ansible
ENigma371, 2021-10-06 17:43:00

How to create kubeadm token with ansible?

Good afternoon!
I'm trying to fire kubeadm token through ansible, googling I found a bunch of similar options, but not one of them works. Tell me what could be the problem

- hosts: master
  become: yes
  gather_facts: false
  tasks:
    - name: get join command
      shell: kubeadm token create --print-join-command
      register: join_command_raw

    - name: set join command
      set_fact:
        join_command: "{{ join_command_raw.stdout_lines[0] }}"


- hosts: node
  become: yes
  tasks:
    - name: join cluster
      shell: "{{ hostvars['master'].join_command_raw }} >> node_joined.txt"
      args:
        chdir: $HOME
        creates: node_joined.txt

Screenshot of the error below.
615db58ec0b6e677488471.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MaxKozlov, 2021-10-06
@MaxKozlov

you have master, apparently, a group, and in hostvars - hosts
look at
https://docs.ansible.com/ansible/latest/user_guide...
in the area
"You can use groups and hostvars together"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question