0

Follow this guide install Kubernetes cluster:

https://kubernetes.io/docs/getting-started-guides/kubeadm/

Master Server

$ kubeadm init
(got token value here)

Check token

# kubeadm token list
TOKEN                     TTL         EXPIRES   USAGES                   DESCRIPTION
abd323.0213903ur10u01r0n   <forever>   <never>   authentication,signing   The default bootstrap token generated by 'kubeadm init'.

Node Server

$ kubeadm join --token <token> <master-ip>:<master-port>

Here need the token got from master server.


If use Ansible to make playbook for this install flow, how to get token value and set to another host?

cloud_cloud
  • 165
  • 2
  • 4
  • 15

1 Answers1

1

You use magic variables for that:

- debug: msg="{{ hostvars['master'].my_token }}"
Konstantin Suvorov
  • 3,996
  • 1
  • 12
  • 13
  • Thank you. I had edited the question and added `Check token` part. That way can get the value from output, but how to catch it? Here `my_token` is where to set? – cloud_cloud May 10 '17 at 09:42
  • Please, take some time to read docs page I linked: [registered variables](http://docs.ansible.com/ansible/playbooks_variables.html#registered-variables). – Konstantin Suvorov May 10 '17 at 09:45