2019-02-01 13:45:46 +08:00
|
|
|
- name: prepare some dirs
|
2021-06-23 14:26:25 +08:00
|
|
|
file: name={{ ETCD_DATA_DIR }} state=directory mode=0700
|
2019-02-01 13:45:46 +08:00
|
|
|
|
2017-11-11 19:14:21 +08:00
|
|
|
- name: 下载etcd二进制文件
|
|
|
|
copy: src={{ base_dir }}/bin/{{ item }} dest={{ bin_dir }}/{{ item }} mode=0755
|
|
|
|
with_items:
|
|
|
|
- etcd
|
|
|
|
- etcdctl
|
2018-12-06 10:04:27 +08:00
|
|
|
tags: upgrade_etcd
|
2017-11-11 19:14:21 +08:00
|
|
|
|
|
|
|
- name: 创建etcd证书请求
|
2020-12-30 11:25:54 +08:00
|
|
|
template: src=etcd-csr.json.j2 dest={{ cluster_dir }}/ssl/etcd-csr.json
|
|
|
|
connection: local
|
2022-09-08 10:15:55 +08:00
|
|
|
run_once: true
|
2022-11-26 10:56:52 +08:00
|
|
|
tags: force_change_certs
|
2017-11-11 19:14:21 +08:00
|
|
|
|
|
|
|
- name: 创建 etcd证书和私钥
|
2020-12-30 11:25:54 +08:00
|
|
|
shell: "cd {{ cluster_dir }}/ssl && {{ base_dir }}/bin/cfssl gencert \
|
|
|
|
-ca=ca.pem \
|
|
|
|
-ca-key=ca-key.pem \
|
|
|
|
-config=ca-config.json \
|
|
|
|
-profile=kubernetes etcd-csr.json | {{ base_dir }}/bin/cfssljson -bare etcd"
|
|
|
|
connection: local
|
2022-09-08 10:15:55 +08:00
|
|
|
run_once: true
|
2022-11-26 10:56:52 +08:00
|
|
|
tags: force_change_certs
|
2020-12-30 11:25:54 +08:00
|
|
|
|
|
|
|
- name: 分发etcd证书相关
|
|
|
|
copy: src={{ cluster_dir }}/ssl/{{ item }} dest={{ ca_dir }}/{{ item }}
|
|
|
|
with_items:
|
|
|
|
- ca.pem
|
|
|
|
- etcd.pem
|
|
|
|
- etcd-key.pem
|
2022-11-26 10:56:52 +08:00
|
|
|
tags: force_change_certs
|
2017-11-11 19:14:21 +08:00
|
|
|
|
|
|
|
- name: 创建etcd的systemd unit文件
|
|
|
|
template: src=etcd.service.j2 dest=/etc/systemd/system/etcd.service
|
2021-01-07 09:30:50 +08:00
|
|
|
tags: upgrade_etcd, restart_etcd
|
2017-11-11 19:14:21 +08:00
|
|
|
|
2018-04-10 18:33:24 +08:00
|
|
|
- name: 开机启用etcd服务
|
|
|
|
shell: systemctl enable etcd
|
|
|
|
ignore_errors: true
|
|
|
|
|
2017-12-05 09:59:56 +08:00
|
|
|
- name: 开启etcd服务
|
2018-04-10 18:33:24 +08:00
|
|
|
shell: systemctl daemon-reload && systemctl restart etcd
|
2018-12-21 10:06:07 +08:00
|
|
|
ignore_errors: true
|
2022-11-26 10:56:52 +08:00
|
|
|
tags: upgrade_etcd, restart_etcd, force_change_certs
|
2018-12-21 10:06:07 +08:00
|
|
|
|
|
|
|
- name: 以轮询的方式等待服务同步完成
|
2021-05-28 10:11:35 +08:00
|
|
|
shell: "systemctl is-active etcd.service"
|
2018-12-21 10:06:07 +08:00
|
|
|
register: etcd_status
|
2021-05-28 10:11:35 +08:00
|
|
|
until: '"active" in etcd_status.stdout'
|
2018-12-21 10:06:07 +08:00
|
|
|
retries: 8
|
|
|
|
delay: 8
|
2022-11-26 10:56:52 +08:00
|
|
|
tags: upgrade_etcd, restart_etcd, force_change_certs
|