2017-09-18 12:30:57 +00:00
|
|
|
---
|
|
|
|
- name: Set external kube-apiserver endpoint
|
|
|
|
set_fact:
|
|
|
|
external_apiserver_endpoint: >-
|
|
|
|
{%- if loadbalancer_apiserver is defined and loadbalancer_apiserver.port is defined -%}
|
2017-11-23 16:15:48 +00:00
|
|
|
https://{{ apiserver_loadbalancer_domain_name }}:{{ loadbalancer_apiserver.port|default(kube_apiserver_port) }}
|
2017-09-18 12:30:57 +00:00
|
|
|
{%- else -%}
|
2018-05-31 14:34:02 +00:00
|
|
|
https://{{ kube_apiserver_access_address }}:{{ kube_apiserver_port }}
|
2017-09-18 12:30:57 +00:00
|
|
|
{%- endif -%}
|
2017-10-05 07:43:04 +00:00
|
|
|
tags:
|
|
|
|
- facts
|
2017-09-18 12:30:57 +00:00
|
|
|
|
|
|
|
- name: Gather certs for admin kubeconfig
|
|
|
|
slurp:
|
|
|
|
src: "{{ item }}"
|
|
|
|
register: admin_certs
|
|
|
|
with_items:
|
|
|
|
- "{{ kube_cert_dir }}/ca.pem"
|
|
|
|
- "{{ kube_cert_dir }}/admin-{{ inventory_hostname }}.pem"
|
|
|
|
- "{{ kube_cert_dir }}/admin-{{ inventory_hostname }}-key.pem"
|
|
|
|
when: not kubeadm_enabled|d(false)|bool
|
|
|
|
|
|
|
|
- name: Write admin kubeconfig
|
|
|
|
template:
|
|
|
|
src: admin.conf.j2
|
|
|
|
dest: "{{ kube_config_dir }}/admin.conf"
|
2017-10-12 08:55:46 +00:00
|
|
|
owner: root
|
|
|
|
group: "{{ kube_cert_group }}"
|
|
|
|
mode: 0640
|
2017-09-18 12:30:57 +00:00
|
|
|
when: not kubeadm_enabled|d(false)|bool
|
|
|
|
|
|
|
|
- name: Create kube config dir
|
|
|
|
file:
|
|
|
|
path: "/root/.kube"
|
|
|
|
mode: "0700"
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: Copy admin kubeconfig to root user home
|
|
|
|
copy:
|
|
|
|
src: "{{ kube_config_dir }}/admin.conf"
|
|
|
|
dest: "/root/.kube/config"
|
|
|
|
remote_src: yes
|
2018-05-14 09:29:48 +00:00
|
|
|
mode: "0600"
|
2017-09-18 12:30:57 +00:00
|
|
|
backup: yes
|
|
|
|
|
|
|
|
- name: Copy admin kubeconfig to ansible host
|
|
|
|
fetch:
|
|
|
|
src: "{{ kube_config_dir }}/admin.conf"
|
|
|
|
dest: "{{ artifacts_dir }}/admin.conf"
|
|
|
|
flat: yes
|
|
|
|
validate_checksum: no
|
|
|
|
run_once: yes
|
|
|
|
when: kubeconfig_localhost|default(false)
|
|
|
|
|
|
|
|
- name: Copy kubectl binary to ansible host
|
|
|
|
fetch:
|
|
|
|
src: "{{ bin_dir }}/kubectl"
|
2018-04-09 10:19:26 +00:00
|
|
|
dest: "{{ artifacts_dir }}/kubectl"
|
2017-09-18 12:30:57 +00:00
|
|
|
flat: yes
|
|
|
|
validate_checksum: no
|
|
|
|
become: no
|
|
|
|
run_once: yes
|
|
|
|
when: kubectl_localhost|default(false)
|
2018-02-16 12:53:35 +00:00
|
|
|
|
|
|
|
- name: create helper script kubectl.sh on ansible host
|
|
|
|
copy:
|
|
|
|
content: |
|
|
|
|
#!/bin/bash
|
|
|
|
kubectl --kubeconfig=admin.conf $@
|
|
|
|
dest: "{{ artifacts_dir }}/kubectl.sh"
|
|
|
|
mode: 0755
|
|
|
|
become: no
|
|
|
|
run_once: yes
|
|
|
|
delegate_to: localhost
|
|
|
|
when: kubectl_localhost|default(false) and kubeconfig_localhost|default(false)
|