c12s-kubespray/roles/kubernetes/master/tasks/config.yml

95 lines
2.8 KiB
YAML
Raw Normal View History

2015-10-03 20:19:50 +00:00
---
- name: get the node token values from token files
slurp:
src: "{{ kube_token_dir }}/{{ item }}-{{ inventory_hostname }}.token"
with_items:
- "system:controller_manager"
- "system:scheduler"
- "system:kubectl"
- "system:proxy"
register: tokens
delegate_to: "{{ groups['kube-master'][0] }}"
- name: Set token facts
set_fact:
controller_manager_token: "{{ tokens.results[0].content|b64decode }}"
scheduler_token: "{{ tokens.results[1].content|b64decode }}"
kubectl_token: "{{ tokens.results[2].content|b64decode }}"
proxy_token: "{{ tokens.results[3].content|b64decode }}"
- name: write the config files for api server
2015-11-20 10:18:37 +00:00
template: src=apiserver.j2 dest={{ kube_config_dir }}/apiserver backup=yes
2015-10-03 20:19:50 +00:00
notify:
- restart apiserver
2015-10-03 20:19:50 +00:00
- name: write config file for controller-manager
2015-11-20 10:18:37 +00:00
template: src=controller-manager.j2 dest={{ kube_config_dir }}/controller-manager backup=yes
2015-10-03 20:19:50 +00:00
notify:
- restart controller-manager
- name: write the kubecfg (auth) file for controller-manager
2015-11-20 10:18:37 +00:00
template: src=controller-manager.kubeconfig.j2 dest={{ kube_config_dir }}/controller-manager.kubeconfig backup=yes
2015-10-03 20:19:50 +00:00
notify:
- restart controller-manager
- name: write the config file for scheduler
2015-11-20 10:18:37 +00:00
template: src=scheduler.j2 dest={{ kube_config_dir }}/scheduler backup=yes
2015-10-03 20:19:50 +00:00
notify:
- restart scheduler
- name: write the kubecfg (auth) file for scheduler
2015-11-20 10:18:37 +00:00
template: src=scheduler.kubeconfig.j2 dest={{ kube_config_dir }}/scheduler.kubeconfig backup=yes
2015-10-03 20:19:50 +00:00
notify:
- restart scheduler
- name: write the kubecfg (auth) file for kubectl
2015-11-20 10:18:37 +00:00
template: src=kubectl.kubeconfig.j2 dest={{ kube_config_dir }}/kubectl.kubeconfig backup=yes
2015-10-03 20:19:50 +00:00
2015-12-01 11:13:22 +00:00
- name: Copy kubectl bash completion
copy: src=kubectl_bash_completion.sh dest=/etc/bash_completion.d/kubectl.sh
2015-11-30 15:41:22 +00:00
- name: Create proxy environment vars dir
file: path=/etc/systemd/system/kube-proxy.service.d state=directory
- name: Write proxy config file
template: src=proxy.j2 dest=/etc/systemd/system/kube-proxy.service.d/10-proxy-cluster.conf backup=yes
2015-10-03 20:19:50 +00:00
notify:
- restart proxy
2015-10-03 20:19:50 +00:00
- name: write the kubecfg (auth) file for proxy
2015-11-20 10:18:37 +00:00
template: src=proxy.kubeconfig.j2 dest={{ kube_config_dir }}/proxy.kubeconfig backup=yes
2015-10-03 20:19:50 +00:00
- name: populate users for basic auth in API
lineinfile:
dest: "{{ kube_users_dir }}/known_users.csv"
create: yes
line: '{{ item.value.pass }},{{ item.key }},{{ item.value.role }}'
2015-11-20 10:18:37 +00:00
backup: yes
2015-10-03 20:19:50 +00:00
with_dict: "{{ kube_users }}"
notify:
- restart apiserver
- name: Enable controller-manager
service:
name: kube-controller-manager
enabled: yes
state: started
- name: Enable scheduler
service:
name: kube-scheduler
enabled: yes
state: started
- name: Enable kube-proxy
service:
name: kube-proxy
enabled: yes
state: started
- name: Enable apiserver
service:
name: kube-apiserver
enabled: yes
state: started