forked from easzlab/kubeasz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.yml
61 lines (51 loc) · 1.69 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 系统基础软件环境
- name: apt更新缓存刷新
apt: update_cache=yes cache_valid_time=72000
ignore_errors: true
when:
- 'ansible_distribution in ["Ubuntu","Debian"]'
- 'INSTALL_SOURCE != "offline"'
- import_tasks: ubuntu.yml
when: 'ansible_distribution in ["Ubuntu","Debian"]'
- import_tasks: centos.yml
when: 'ansible_distribution in ["CentOS","RedHat","Amazon"]'
# 公共系统参数设置
- import_tasks: common.yml
- name: prepare some dirs
file: name={{ item }} state=directory
with_items:
- "{{ bin_dir }}"
- "{{ ca_dir }}"
- /root/.kube
- name: 分发证书工具 CFSSL
copy: src={{ base_dir }}/bin/{{ item }} dest={{ bin_dir }}/{{ item }} mode=0755
with_items:
- cfssl
- cfssl-certinfo
- cfssljson
- name: 写入环境变量$PATH
lineinfile:
dest: ~/.bashrc
state: present
regexp: 'kubeasz'
line: 'export PATH={{ bin_dir }}:$PATH # generated by kubeasz'
- block:
- name: 分发证书相关
copy: src={{ base_dir }}/.cluster/ssl/{{ item }} dest={{ ca_dir }}/{{ item }}
with_items:
- admin.pem
- admin-key.pem
- ca.pem
- ca-key.pem
- ca-config.json
- name: 添加 kubectl 命令自动补全
lineinfile:
dest: ~/.bashrc
state: present
regexp: 'kubectl completion'
line: 'source <(kubectl completion bash)'
- name: 分发 kubeconfig配置文件
copy: src=/root/.kube/config dest=/root/.kube/config
- name: 分发 kube-proxy.kubeconfig配置文件
copy: src={{ base_dir }}/.cluster/kube-proxy.kubeconfig dest=/etc/kubernetes/kube-proxy.kubeconfig
when: "inventory_hostname in groups['kube-master'] or inventory_hostname in groups['kube-node']"