parent
07902c3067
commit
d090201ed7
@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
- name: Set up kubectl
|
||||||
|
hosts: localhost
|
||||||
|
connection: local
|
||||||
|
vars:
|
||||||
|
uid: "{{ lookup('env', 'USER') }}"
|
||||||
|
cert_test: "{{ lookup('ansible.builtin.pipe', 'pass show kube1.drive.test.sunet.se/cert') }}"
|
||||||
|
token_test: "{{ lookup('ansible.builtin.pipe', 'pass show kube1.drive.test.sunet.se/token') }}"
|
||||||
|
cert_prod: "{{ lookup('ansible.builtin.pipe', 'pass show kube1.drive.sunet.se/cert') }}"
|
||||||
|
token_prod: "{{ lookup('ansible.builtin.pipe', 'pass show kube1.drive.sunet.se/token') }}"
|
||||||
|
become: false
|
||||||
|
tasks:
|
||||||
|
- name: Set up kubectl keyring
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: bash -c "curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg"
|
||||||
|
become: true
|
||||||
|
- name: Set up kubectl apt repo
|
||||||
|
ansible.builtin.apt_repository:
|
||||||
|
repo: deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /
|
||||||
|
state: present
|
||||||
|
update_cache: yes
|
||||||
|
become: true
|
||||||
|
- name: Install kubectl package
|
||||||
|
become: true
|
||||||
|
ansible.builtin.apt:
|
||||||
|
autoclean: true
|
||||||
|
autoremove: true
|
||||||
|
install_recommends: true
|
||||||
|
pkg:
|
||||||
|
- kubectl
|
||||||
|
- name: Add kube.conf dir
|
||||||
|
ansible.builtin.file:
|
||||||
|
dest: /home/{{ uid }}/.kube
|
||||||
|
state: directory
|
||||||
|
- name: Add kube.conf
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: ../templates/kube.conf.j2
|
||||||
|
dest: /home/{{ uid }}/.kube/config
|
@ -0,0 +1,29 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
clusters:
|
||||||
|
- cluster:
|
||||||
|
certificate-authority-data: {{ cert_test }}
|
||||||
|
server: https://89.46.21.107:16443
|
||||||
|
name: drive-test
|
||||||
|
- cluster:
|
||||||
|
certificate-authority-data: {{ cert_prod }}
|
||||||
|
server: https://89.46.20.196:16443
|
||||||
|
name: drive-prod
|
||||||
|
contexts:
|
||||||
|
- context:
|
||||||
|
cluster: drive-test
|
||||||
|
user: drive-test
|
||||||
|
name: drive-test
|
||||||
|
- context:
|
||||||
|
cluster: drive-prod
|
||||||
|
user: drive-prod
|
||||||
|
name: drive-prod
|
||||||
|
current-context: drive-test
|
||||||
|
kind: Config
|
||||||
|
preferences: {}
|
||||||
|
users:
|
||||||
|
- name: drive-test
|
||||||
|
user:
|
||||||
|
token: {{ token_test }}
|
||||||
|
- name: drive-prod
|
||||||
|
user:
|
||||||
|
token: {{ token_prod }}
|
Loading…
Reference in new issue