Skip to content

Instantly share code, notes, and snippets.

@consolewitch
Created July 17, 2018 22:18
Show Gist options
  • Save consolewitch/7fc756d3004112887a756a23b4ff26e4 to your computer and use it in GitHub Desktop.
Save consolewitch/7fc756d3004112887a756a23b4ff26e4 to your computer and use it in GitHub Desktop.
ansible role (tasks/main.yaml) to install k8s on an ubuntu server.
---
- name: "Disable swap"
command: "swapoff -a"
- name: "Remove swap from fstab"
lineinfile:
path: /etc/fstab
state: absent
regexp: '^.*(\t| )swap(\t| )sw(\t| ).*$'
- name: "Install necessary key signature checking keys and tools"
apt:
name: "{{ item }}"
state: latest
update_cache: true
with_items:
- ethtool
- ebtables
- apt-transport-https
- name: "Add kubernetes's GPG key to apt"
apt_key:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
- name: "Add kubernetes apt repo"
apt_repository:
repo: "deb http://apt.kubernetes.io/ kubernetes-xenial main"
state: present
update_cache: yes
- name: "Remove old versions of kubernetes tools"
apt:
name: "{{ item.name }}"
state: absent
with_items:
- { name: kubernetes-cni, version: 0.5.1-00 } #Order matters. This must be first
- { name: kubelet, version: 1.8.13 }
- { name: kubectl, version: 1.8.13 }
- { name: kubeadm, version: 1.8.13 }
- name: "Install Kubernetes"
apt:
update_cache: true
name: "{{ item.name }}={{ item.version }}*"
state: present
with_items:
- { name: kubernetes-cni, version: 0.5.1-00 } #Order matters. This must be first
- { name: kubelet, version: 1.8.13 } #second
- { name: kubectl, version: 1.8.13 } #third
- { name: kubeadm, version: 1.8.13 } #forth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment