You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.4 KiB

1 year ago
---
- 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