summaryrefslogtreecommitdiffstats
path: root/ansible/roles/rancher
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/roles/rancher')
-rw-r--r--ansible/roles/rancher/defaults/main.yml2
-rw-r--r--ansible/roles/rancher/tasks/rancher_server.yml10
-rw-r--r--ansible/roles/rancher/templates/kube_config.j219
3 files changed, 31 insertions, 0 deletions
diff --git a/ansible/roles/rancher/defaults/main.yml b/ansible/roles/rancher/defaults/main.yml
index 6d354e6e..e4e12d23 100644
--- a/ansible/roles/rancher/defaults/main.yml
+++ b/ansible/roles/rancher/defaults/main.yml
@@ -4,6 +4,8 @@ rancher_remove_other_env: true
rancher_redeploy_k8s_env: true
rancher_cluster_health_state: healthy
rancher_cluster_health_check_retries: 30
+kube_directory: ~/.kube
+kube_server: "https://{{ ansible_host }}:8080/r/projects/{{ k8s_env_id | mandatory }}/kubernetes:6443"
rancher:
# The following variables can be set via the UI under advanced/settings.
# All of these affect tables in the cattle db and are uninteresting
diff --git a/ansible/roles/rancher/tasks/rancher_server.yml b/ansible/roles/rancher/tasks/rancher_server.yml
index a0893b0b..f467ff3f 100644
--- a/ansible/roles/rancher/tasks/rancher_server.yml
+++ b/ansible/roles/rancher/tasks/rancher_server.yml
@@ -93,3 +93,13 @@
data:
option: audit_log.purge.after.seconds
value: "{{ rancher.audit_log_purge_after_seconds }}"
+
+- name: Ensure .kube directory exists
+ file:
+ path: "{{ kube_directory }}"
+ state: directory
+
+- name: Create kube config
+ template:
+ src: kube_config.j2
+ dest: "{{ kube_directory }}/config"
diff --git a/ansible/roles/rancher/templates/kube_config.j2 b/ansible/roles/rancher/templates/kube_config.j2
new file mode 100644
index 00000000..586c59d4
--- /dev/null
+++ b/ansible/roles/rancher/templates/kube_config.j2
@@ -0,0 +1,19 @@
+apiVersion: v1
+kind: Config
+clusters:
+- cluster:
+ api-version: v1
+ insecure-skip-tls-verify: true
+ server: "{{ kube_server }}"
+ name: "{{ app_name }}"
+contexts:
+- context:
+ cluster: "{{ app_name }}"
+ user: "{{ app_name }}"
+ name: "{{ app_name }}"
+current-context: "{{ app_name }}"
+users:
+- name: "{{ app_name }}"
+ user:
+ token: "{{ (['Basic', [key_public, key_private] | join(':') | b64encode] | join(' ')) | b64encode }}"
+