2016-02-11 22:08:16 +00:00
|
|
|
---
|
2016-04-07 15:08:39 +00:00
|
|
|
- include: check-certs.yml
|
2016-12-08 13:36:00 +00:00
|
|
|
tags: [k8s-secrets, facts]
|
2017-02-17 21:22:34 +00:00
|
|
|
|
2016-05-06 17:17:59 +00:00
|
|
|
- include: check-tokens.yml
|
2016-12-08 13:36:00 +00:00
|
|
|
tags: [k8s-secrets, facts]
|
2016-04-07 15:08:39 +00:00
|
|
|
|
2016-02-11 22:08:16 +00:00
|
|
|
- name: Make sure the certificate directory exits
|
|
|
|
file:
|
2017-02-17 21:22:34 +00:00
|
|
|
path: "{{ kube_cert_dir }}"
|
|
|
|
state: directory
|
|
|
|
mode: o-rwx
|
|
|
|
group: "{{ kube_cert_group }}"
|
2016-02-11 22:08:16 +00:00
|
|
|
|
|
|
|
- name: Make sure the tokens directory exits
|
|
|
|
file:
|
2017-02-17 21:22:34 +00:00
|
|
|
path: "{{ kube_token_dir }}"
|
|
|
|
state: directory
|
|
|
|
mode: o-rwx
|
|
|
|
group: "{{ kube_cert_group }}"
|
2016-02-11 22:08:16 +00:00
|
|
|
|
|
|
|
- name: Make sure the users directory exits
|
|
|
|
file:
|
2017-02-17 21:22:34 +00:00
|
|
|
path: "{{ kube_users_dir }}"
|
|
|
|
state: directory
|
|
|
|
mode: o-rwx
|
|
|
|
group: "{{ kube_cert_group }}"
|
2016-02-11 22:08:16 +00:00
|
|
|
|
|
|
|
- name: Populate users for basic auth in API
|
2017-07-14 13:27:20 +00:00
|
|
|
template:
|
|
|
|
src: known_users.csv.j2
|
2016-02-11 22:08:16 +00:00
|
|
|
dest: "{{ kube_users_dir }}/known_users.csv"
|
|
|
|
backup: yes
|
2017-02-27 13:15:50 +00:00
|
|
|
when: inventory_hostname in "{{ groups['kube-master'] }}" and kube_basic_auth|default(true)
|
2016-02-11 22:08:16 +00:00
|
|
|
notify: set secret_changed
|
|
|
|
|
2017-01-15 05:24:34 +00: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-18 20:06:50 +00:00
|
|
|
- name: "Gen_certs | Create kubernetes config directory (on {{groups['kube-master'][0]}})"
|
2017-01-15 05:24:34 +00:00
|
|
|
file:
|
|
|
|
path: "{{ kube_config_dir }}"
|
|
|
|
state: directory
|
|
|
|
owner: kube
|
|
|
|
run_once: yes
|
|
|
|
delegate_to: "{{groups['kube-master'][0]}}"
|
|
|
|
tags: [kubelet, k8s-secrets, kube-controller-manager, kube-apiserver, bootstrap-os, apps, network, master, node]
|
|
|
|
when: gen_certs|default(false) or gen_tokens|default(false)
|
|
|
|
|
2017-01-18 20:06:50 +00:00
|
|
|
- name: "Gen_certs | Create kubernetes script directory (on {{groups['kube-master'][0]}})"
|
2017-01-15 05:24:34 +00:00
|
|
|
file:
|
|
|
|
path: "{{ kube_script_dir }}"
|
|
|
|
state: directory
|
|
|
|
owner: kube
|
|
|
|
run_once: yes
|
|
|
|
delegate_to: "{{groups['kube-master'][0]}}"
|
|
|
|
tags: [k8s-secrets, bootstrap-os]
|
|
|
|
when: gen_certs|default(false) or gen_tokens|default(false)
|
|
|
|
|
2017-01-18 20:06:50 +00:00
|
|
|
- name: "Get_tokens | Make sure the tokens directory exits (on {{groups['kube-master'][0]}})"
|
2017-01-15 05:24:34 +00:00
|
|
|
file:
|
2017-02-17 21:22:34 +00:00
|
|
|
path: "{{ kube_token_dir }}"
|
|
|
|
state: directory
|
|
|
|
mode: o-rwx
|
|
|
|
group: "{{ kube_cert_group }}"
|
2017-01-15 05:24:34 +00:00
|
|
|
run_once: yes
|
|
|
|
delegate_to: "{{groups['kube-master'][0]}}"
|
|
|
|
when: gen_tokens|default(false)
|
|
|
|
|
2017-03-03 13:33:00 +00:00
|
|
|
- include: "gen_certs_{{ cert_management }}.yml"
|
2016-12-08 13:36:00 +00:00
|
|
|
tags: k8s-secrets
|
2017-02-08 21:41:36 +00:00
|
|
|
|
2017-08-30 13:03:22 +00:00
|
|
|
- include: upd_ca_trust.yml
|
|
|
|
tags: k8s-secrets
|
|
|
|
|
2017-09-01 06:02:23 +00: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"
|
|
|
|
with_items:
|
|
|
|
- "admin-{{ inventory_hostname }}.pem"
|
|
|
|
- "apiserver.pem"
|
|
|
|
- "kube-controller-manager.pem"
|
|
|
|
- "kube-scheduler.pem"
|
|
|
|
when: inventory_hostname in groups['kube-master']
|
|
|
|
|
|
|
|
- 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']
|
|
|
|
|
|
|
|
- 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"
|
|
|
|
with_items:
|
|
|
|
- "node-{{ inventory_hostname }}.pem"
|
|
|
|
- "kube-proxy-{{ inventory_hostname }}.pem"
|
|
|
|
when: inventory_hostname in groups['k8s-cluster']
|
|
|
|
|
|
|
|
- name: "Gen_certs | set kube node certificate serial facts"
|
|
|
|
set_fact:
|
|
|
|
etcd_node_cert_serial: "{{ node_certificate_serials.results[0].stdout|default() }}"
|
|
|
|
kube_proxy_cert_serial: "{{ node_certificate_serials.results[1].stdout|default() }}"
|
|
|
|
when: inventory_hostname in groups['k8s-cluster']
|
|
|
|
|
2016-02-11 22:08:16 +00:00
|
|
|
- include: gen_tokens.yml
|
2016-12-08 13:36:00 +00:00
|
|
|
tags: k8s-secrets
|