snapy playbook to install kubernetes repo and tools

This commit is contained in:
Ibrahim Mkusa 2024-11-16 13:10:31 -05:00
parent c895037e69
commit 1f9947ca8d
3 changed files with 42 additions and 2 deletions

View File

@ -5,13 +5,15 @@ localhost
192.168.2.236 192.168.2.236
[docker] [docker]
node1 ansible_user=ansible docker0 ansible_user=ansible
[aws] [aws]
aws ansible_user=ubuntu aws ansible_user=ubuntu
[helm] [helm]
node1 ansible_user=ansible node1 ansible_user=ansible
node4 ansible_user=ansible
[terraform] [terraform]
node1 node1

View File

@ -1,6 +1,6 @@
--- ---
- name: install terraform on deb/rpm family - name: install terraform on deb/rpm family
hosts: terraform hosts: localhost
become: yes become: yes
tasks: tasks:
- name: update cache on debian/rpm family - name: update cache on debian/rpm family

View File

@ -0,0 +1,38 @@
---
- name: adds the kubernetes repo and installs kubectl
hosts: localhost
become: true
tasks:
- name: update apt cache
ansible.builtin.apt:
update_cache: true
- name: install core pre-reqs
ansible.builtin.apt:
pkg:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- name: check to see if gpg key exists
ansible.builtin.stat:
path: /etc/apt/keyrings/kubernetes-apt-keyring.gpg
register: st
- 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
- 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
- name: update apt cache and install kubectl
ansible.builtin.apt:
name: kubectl
update_cache: true