forked from easzlab/kubeasz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.yml
More file actions
39 lines (32 loc) · 1.38 KB
/
main.yml
File metadata and controls
39 lines (32 loc) · 1.38 KB
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
- name: 下载etcd二进制文件
copy: src={{ base_dir }}/bin/{{ item }} dest={{ bin_dir }}/{{ item }} mode=0755
with_items:
- etcd
- etcdctl
# 注册变量result,根据result结果判断是否已经生成过etcd证书
# result|failed 说明没有生成过证书,下一步生成证书
# result|succeeded 说明已经有etcd证书,使用原证书可以保证api-server和calico/node等对etcd集群
# 的访问不受影响,因此跳过证书生成的步骤
- name: 注册变量result
command: ls /etc/etcd/ssl/etcd.pem
register: result
ignore_errors: True
- name: 创建etcd证书目录
file: name=/etc/etcd/ssl state=directory
when: result|failed
- name: 创建etcd证书请求
template: src=etcd-csr.json.j2 dest=/etc/etcd/ssl/etcd-csr.json
when: result|failed
- name: 创建 etcd证书和私钥
shell: "cd /etc/etcd/ssl && {{ bin_dir }}/cfssl gencert \
-ca={{ ca_dir }}/ca.pem \
-ca-key={{ ca_dir }}/ca-key.pem \
-config={{ ca_dir }}/ca-config.json \
-profile=kubernetes etcd-csr.json | {{ bin_dir }}/cfssljson -bare etcd"
when: result|failed
- name: 创建etcd工作目录
file: name=/var/lib/etcd state=directory
- name: 创建etcd的systemd unit文件
template: src=etcd.service.j2 dest=/etc/systemd/system/etcd.service
- name: 开启etcd服务
shell: systemctl daemon-reload && systemctl enable etcd && systemctl restart etcd