maabara/playbooks/k8s/install_kubectl.yml

58 lines
1.8 KiB
YAML
Raw Normal View History

---
- name: adds the kubernetes repo and installs kubectl
hosts: all
tasks:
- name: update apt cache
ansible.builtin.apt:
update_cache: true
become: true
- name: install core pre-reqs
ansible.builtin.apt:
pkg:
- apt-transport-https
- ca-certificates
- curl
- gnupg
become: true
- name: check to see if gpg key exists
ansible.builtin.stat:
path: /etc/apt/keyrings/kubernetes-apt-keyring.gpg
register: st
become: true
- name: download the key and install it
ansible.builtin.shell: |
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
sudo chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg # allow unprivileged APT programs to read this keyring
when: st.stat.exists != true
become: true
- name: add the kubernetes apt repository
ansible.builtin.apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /"
state: present
filename: kubernetes.list
become: true
- name: update apt cache and install kubectl
ansible.builtin.apt:
name: kubectl
update_cache: true
become: true
2024-11-16 18:32:11 +00:00
- name: does argocd exists
ansible.builtin.stat:
path: /usr/local/bin/argocd
register: st
- name: install argocd
ansible.builtin.shell: |
VERSION=$(curl -L -s https://raw.githubusercontent.com/argoproj/argo-cd/stable/VERSION)
curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/download/v$VERSION/argocd-linux-amd64
sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd
rm argocd-linux-amd64
when: st.stat.exists != true
become: true