2019-01-22 12:10:16 +00:00
|
|
|
---
|
2019-01-25 18:04:04 +00:00
|
|
|
- hosts: k8s-masters
|
2019-01-22 12:10:16 +00:00
|
|
|
remote_user: hybris
|
|
|
|
become: yes
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: initialize kubernetes master
|
2019-01-25 18:04:04 +00:00
|
|
|
shell: kubeadm init --apiserver-advertise-address=2001:470:6d:22c:42::1 --pod-network-cidr=2001:470:6d:22c::/64
|
2019-01-22 12:10:16 +00:00
|
|
|
delegate_to: k8s-master.e2m
|
|
|
|
run_once: yes
|
|
|
|
|
|
|
|
- shell: kubeadm token create --print-join-command
|
|
|
|
register: results
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
var: results.stdout
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
k8s_token: "{{ results.stdout | regex_search(regexp, '\\2') | first }}"
|
|
|
|
vars:
|
|
|
|
regexp: '([^\s]+\s){4}([^\s]+)'
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
var: k8s_token
|
|
|
|
|
|
|
|
- set_fact:
|
|
|
|
k8s_ca_cert_hash: "{{ results.stdout | regex_search(regexp, '\\2') | first }}"
|
|
|
|
vars:
|
|
|
|
regexp: '([^\s]+\s){6}([^\s]+)'
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
var: k8s_ca_cert_hash
|
|
|
|
|
|
|
|
- name: join nodes to cluster
|
|
|
|
shell: kubeadm join [2001:470:6d:22c:42::1]:6443 --token {{ k8s_token }} --discovery-token-ca-cert-hash sha256:{{ k8s_ca_cert_hash }}
|
2019-01-25 18:04:04 +00:00
|
|
|
delegate_to: "{{ item }}"
|
|
|
|
with_items: "{{ k8s-nodes }}"
|