c12s-kubespray/roles/kubernetes/node/tasks/gen_tokens.yml

56 lines
1.8 KiB
YAML
Raw Normal View History

2015-10-03 20:19:50 +00:00
---
- name: tokens | copy the token gen script
copy:
src=kube-gen-token.sh
dest={{ kube_script_dir }}
mode=u+x
2015-12-19 10:00:22 +00:00
when: inventory_hostname == groups['kube-master'][0]
2015-10-03 20:19:50 +00:00
- name: tokens | generate tokens for master components
command: "{{ kube_script_dir }}/kube-gen-token.sh {{ item[0] }}-{{ item[1] }}"
environment:
TOKEN_DIR: "{{ kube_token_dir }}"
with_nested:
- [ "system:kubectl" ]
- "{{ groups['kube-master'] }}"
2015-10-03 20:19:50 +00:00
register: gentoken
changed_when: "'Added' in gentoken.stdout"
2015-12-19 10:00:22 +00:00
when: inventory_hostname == groups['kube-master'][0]
2015-10-03 20:19:50 +00:00
- name: tokens | generate tokens for node components
command: "{{ kube_script_dir }}/kube-gen-token.sh {{ item[0] }}-{{ item[1] }}"
environment:
TOKEN_DIR: "{{ kube_token_dir }}"
with_nested:
- [ 'system:kubelet' ]
2015-10-03 20:19:50 +00:00
- "{{ groups['kube-node'] }}"
register: gentoken
changed_when: "'Added' in gentoken.stdout"
2015-12-19 10:00:22 +00:00
when: inventory_hostname == groups['kube-master'][0]
- name: tokens | generate tokens for calico
command: "{{ kube_script_dir }}/kube-gen-token.sh {{ item[0] }}-{{ item[1] }}"
environment:
TOKEN_DIR: "{{ kube_token_dir }}"
with_nested:
- [ "system:calico" ]
- "{{ groups['k8s-cluster'] }}"
register: gentoken
changed_when: "'Added' in gentoken.stdout"
when: kube_network_plugin == "calico"
delegate_to: "{{ groups['kube-master'][0] }}"
- name: tokens | get the calico token values
slurp:
src: "{{ kube_token_dir }}/system:calico-{{ inventory_hostname }}.token"
register: calico_token
when: kube_network_plugin == "calico"
delegate_to: "{{ groups['kube-master'][0] }}"
- name: tokens | Add KUBE_AUTH_TOKEN for calico
lineinfile:
regexp: "^KUBE_AUTH_TOKEN=.*$"
line: "KUBE_AUTH_TOKEN={{ calico_token.content|b64decode }}"
dest: "/etc/network-environment"
when: kube_network_plugin == "calico"