2016-02-12 06:08:16 +08:00
|
|
|
---
|
2018-01-29 19:37:48 +08:00
|
|
|
- import_tasks: check-certs.yml
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- k8s-secrets
|
2018-07-06 14:12:13 +08:00
|
|
|
- k8s-gen-certs
|
2017-10-05 15:43:04 +08:00
|
|
|
- facts
|
2017-02-18 05:22:34 +08:00
|
|
|
|
2018-01-29 19:37:48 +08:00
|
|
|
- import_tasks: check-tokens.yml
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- k8s-secrets
|
2018-07-06 14:12:13 +08:00
|
|
|
- k8s-gen-tokens
|
2017-10-05 15:43:04 +08:00
|
|
|
- facts
|
2016-04-07 23:08:39 +08:00
|
|
|
|
2016-02-12 06:08:16 +08:00
|
|
|
- name: Make sure the certificate directory exits
|
|
|
|
file:
|
2017-02-18 05:22:34 +08:00
|
|
|
path: "{{ kube_cert_dir }}"
|
|
|
|
state: directory
|
|
|
|
mode: o-rwx
|
|
|
|
group: "{{ kube_cert_group }}"
|
2016-02-12 06:08:16 +08:00
|
|
|
|
|
|
|
- name: Make sure the tokens directory exits
|
|
|
|
file:
|
2017-02-18 05:22:34 +08:00
|
|
|
path: "{{ kube_token_dir }}"
|
|
|
|
state: directory
|
|
|
|
mode: o-rwx
|
|
|
|
group: "{{ kube_cert_group }}"
|
2016-02-12 06:08:16 +08:00
|
|
|
|
2017-01-15 13:24:34 +08:00
|
|
|
#
|
|
|
|
# The following directory creates make sure that the directories
|
|
|
|
# exist on the first master for cases where the first master isn't
|
|
|
|
# being run.
|
|
|
|
#
|
2017-01-19 04:06:50 +08:00
|
|
|
- name: "Gen_certs | Create kubernetes config directory (on {{groups['kube-master'][0]}})"
|
2017-01-15 13:24:34 +08:00
|
|
|
file:
|
|
|
|
path: "{{ kube_config_dir }}"
|
|
|
|
state: directory
|
|
|
|
owner: kube
|
|
|
|
run_once: yes
|
|
|
|
delegate_to: "{{groups['kube-master'][0]}}"
|
|
|
|
when: gen_certs|default(false) or gen_tokens|default(false)
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- kubelet
|
|
|
|
- k8s-secrets
|
|
|
|
- kube-controller-manager
|
|
|
|
- kube-apiserver
|
|
|
|
- apps
|
|
|
|
- network
|
|
|
|
- master
|
|
|
|
- node
|
2017-01-15 13:24:34 +08:00
|
|
|
|
2017-01-19 04:06:50 +08:00
|
|
|
- name: "Gen_certs | Create kubernetes script directory (on {{groups['kube-master'][0]}})"
|
2017-01-15 13:24:34 +08:00
|
|
|
file:
|
|
|
|
path: "{{ kube_script_dir }}"
|
|
|
|
state: directory
|
|
|
|
owner: kube
|
|
|
|
run_once: yes
|
|
|
|
delegate_to: "{{groups['kube-master'][0]}}"
|
|
|
|
when: gen_certs|default(false) or gen_tokens|default(false)
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- k8s-secrets
|
2017-01-15 13:24:34 +08:00
|
|
|
|
2017-01-19 04:06:50 +08:00
|
|
|
- name: "Get_tokens | Make sure the tokens directory exits (on {{groups['kube-master'][0]}})"
|
2017-01-15 13:24:34 +08:00
|
|
|
file:
|
2017-02-18 05:22:34 +08:00
|
|
|
path: "{{ kube_token_dir }}"
|
|
|
|
state: directory
|
|
|
|
mode: o-rwx
|
|
|
|
group: "{{ kube_cert_group }}"
|
2017-01-15 13:24:34 +08:00
|
|
|
run_once: yes
|
|
|
|
delegate_to: "{{groups['kube-master'][0]}}"
|
|
|
|
when: gen_tokens|default(false)
|
|
|
|
|
2018-11-11 00:51:24 +08:00
|
|
|
- include_tasks: "gen_certs_script.yml"
|
|
|
|
when:
|
|
|
|
- cert_management |d('script') == 'script'
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- k8s-secrets
|
2018-07-06 14:12:13 +08:00
|
|
|
- k8s-gen-certs
|
2017-02-09 05:41:36 +08:00
|
|
|
|
2018-01-29 19:37:48 +08:00
|
|
|
- import_tasks: upd_ca_trust.yml
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- k8s-secrets
|
2018-07-06 14:12:13 +08:00
|
|
|
- k8s-gen-certs
|
2017-08-30 21:03:22 +08:00
|
|
|
|
2017-09-01 14:02:23 +08:00
|
|
|
- name: "Gen_certs | Get certificate serials on kube masters"
|
|
|
|
shell: "openssl x509 -in {{ kube_cert_dir }}/{{ item }} -noout -serial | cut -d= -f2"
|
|
|
|
register: "master_certificate_serials"
|
2017-11-06 21:51:07 +08:00
|
|
|
changed_when: false
|
2017-09-01 14:02:23 +08:00
|
|
|
with_items:
|
|
|
|
- "admin-{{ inventory_hostname }}.pem"
|
|
|
|
- "apiserver.pem"
|
|
|
|
- "kube-controller-manager.pem"
|
|
|
|
- "kube-scheduler.pem"
|
|
|
|
when: inventory_hostname in groups['kube-master']
|
2018-07-06 14:12:13 +08:00
|
|
|
tags:
|
|
|
|
- master
|
|
|
|
- kubelet
|
|
|
|
- node
|
2017-09-01 14:02:23 +08:00
|
|
|
|
|
|
|
- name: "Gen_certs | set kube master certificate serial facts"
|
|
|
|
set_fact:
|
|
|
|
etcd_admin_cert_serial: "{{ master_certificate_serials.results[0].stdout|default() }}"
|
|
|
|
apiserver_cert_serial: "{{ master_certificate_serials.results[1].stdout|default() }}"
|
|
|
|
controller_manager_cert_serial: "{{ master_certificate_serials.results[2].stdout|default() }}"
|
|
|
|
scheduler_cert_serial: "{{ master_certificate_serials.results[3].stdout|default() }}"
|
|
|
|
when: inventory_hostname in groups['kube-master']
|
2018-07-06 14:12:13 +08:00
|
|
|
tags:
|
|
|
|
- master
|
|
|
|
- kubelet
|
|
|
|
- node
|
2017-09-01 14:02:23 +08:00
|
|
|
|
|
|
|
- name: "Gen_certs | Get certificate serials on kube nodes"
|
|
|
|
shell: "openssl x509 -in {{ kube_cert_dir }}/{{ item }} -noout -serial | cut -d= -f2"
|
|
|
|
register: "node_certificate_serials"
|
2017-11-06 21:51:07 +08:00
|
|
|
changed_when: false
|
2017-09-01 14:02:23 +08:00
|
|
|
with_items:
|
|
|
|
- "node-{{ inventory_hostname }}.pem"
|
|
|
|
- "kube-proxy-{{ inventory_hostname }}.pem"
|
2018-10-16 22:15:05 +08:00
|
|
|
when:
|
|
|
|
- inventory_hostname in groups['k8s-cluster']
|
|
|
|
tags:
|
|
|
|
- node
|
|
|
|
- kube-proxy
|
2017-09-01 14:02:23 +08:00
|
|
|
|
|
|
|
- name: "Gen_certs | set kube node certificate serial facts"
|
|
|
|
set_fact:
|
2017-09-14 02:00:51 +08:00
|
|
|
kubelet_cert_serial: "{{ node_certificate_serials.results[0].stdout|default() }}"
|
2017-09-01 14:02:23 +08:00
|
|
|
kube_proxy_cert_serial: "{{ node_certificate_serials.results[1].stdout|default() }}"
|
|
|
|
when: inventory_hostname in groups['k8s-cluster']
|
2018-07-06 14:12:13 +08:00
|
|
|
tags:
|
|
|
|
- kubelet
|
|
|
|
- node
|
2018-10-16 22:15:05 +08:00
|
|
|
- kube-proxy
|
2017-09-01 14:02:23 +08:00
|
|
|
|
2018-01-29 19:37:48 +08:00
|
|
|
- import_tasks: gen_tokens.yml
|
2017-10-05 15:43:04 +08:00
|
|
|
tags:
|
|
|
|
- k8s-secrets
|
2018-07-06 14:12:13 +08:00
|
|
|
- k8s-gen-tokens
|