2024-11-16 18:10:31 +00:00
|
|
|
---
|
|
|
|
- name: adds the kubernetes repo and installs kubectl
|
2024-11-19 00:06:38 +00:00
|
|
|
hosts: all
|
2024-11-16 18:10:31 +00:00
|
|
|
tasks:
|
|
|
|
- name: update apt cache
|
|
|
|
ansible.builtin.apt:
|
|
|
|
update_cache: true
|
2024-11-19 00:06:38 +00:00
|
|
|
become: true
|
2024-11-16 18:10:31 +00:00
|
|
|
|
|
|
|
- name: install core pre-reqs
|
|
|
|
ansible.builtin.apt:
|
|
|
|
pkg:
|
|
|
|
- apt-transport-https
|
|
|
|
- ca-certificates
|
|
|
|
- curl
|
|
|
|
- gnupg
|
2024-11-19 00:06:38 +00:00
|
|
|
become: true
|
2024-11-16 18:10:31 +00:00
|
|
|
|
|
|
|
- name: check to see if gpg key exists
|
|
|
|
ansible.builtin.stat:
|
|
|
|
path: /etc/apt/keyrings/kubernetes-apt-keyring.gpg
|
|
|
|
register: st
|
2024-11-19 00:06:38 +00:00
|
|
|
become: true
|
2024-11-16 18:10:31 +00:00
|
|
|
|
|
|
|
- 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
|
2024-11-19 00:06:38 +00:00
|
|
|
become: true
|
2024-11-16 18:10:31 +00:00
|
|
|
|
|
|
|
- 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
|
2024-11-19 00:06:38 +00:00
|
|
|
become: true
|
2024-11-16 18:10:31 +00:00
|
|
|
|
|
|
|
- name: update apt cache and install kubectl
|
|
|
|
ansible.builtin.apt:
|
|
|
|
name: kubectl
|
|
|
|
update_cache: true
|
2024-11-19 00:06:38 +00:00
|
|
|
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
|
2024-11-19 00:06:38 +00:00
|
|
|
become: true
|