kubeasz/roles/ca/tasks/main.yml

31 lines
942 B
YAML

- name: prepare some dirs
file: name={{ item }} state=directory
with_items:
- "{{ bin_dir }}"
- "{{ ca_dir }}"
- "{{ base_dir }}/roles/calico/files/"
- "{{ base_dir }}/roles/prepare/files/"
- name: 下载证书工具 CFSSL
copy: src={{ base_dir }}/bin/{{ item }} dest={{ bin_dir }}/{{ item }} mode=0755
with_items:
- cfssl
- cfssl-certinfo
- cfssljson
- name: 准备CA配置文件
template: src=ca-config.json.j2 dest={{ ca_dir }}/ca-config.json
- name: 准备CA签名请求
template: src=ca-csr.json.j2 dest={{ ca_dir }}/ca-csr.json
- name: 生成 CA 证书和私钥
shell: "cd {{ ca_dir }} && {{ bin_dir }}/cfssl gencert -initca ca-csr.json | {{ bin_dir }}/cfssljson -bare ca"
- name: 准备分发 CA证书
shell: "cd {{ ca_dir }} && cp ca* {{ base_dir }}/roles/prepare/files/"
- name: 复制 CA证书生成calico secret 使用
shell: "cp -f {{ ca_dir }}/ca.pem {{ base_dir }}/roles/calico/files/"