summaryrefslogtreecommitdiff
path: root/roles/kubernetes/base/tasks/main.yml
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2018-05-24 23:53:00 +0200
committerChristian Pointner <equinox@spreadspace.org>2018-05-24 23:53:00 +0200
commitaef8d86e4b1fc2970e27e578a6dd92ae3024f933 (patch)
tree344e8ecb39db7d8d3735bc0309437ffbf9a16a04 /roles/kubernetes/base/tasks/main.yml
parentmove vm roles to subdir (diff)
move kubernetes roles to subdir
Diffstat (limited to 'roles/kubernetes/base/tasks/main.yml')
-rw-r--r--roles/kubernetes/base/tasks/main.yml90
1 files changed, 90 insertions, 0 deletions
diff --git a/roles/kubernetes/base/tasks/main.yml b/roles/kubernetes/base/tasks/main.yml
new file mode 100644
index 00000000..cc3bc83a
--- /dev/null
+++ b/roles/kubernetes/base/tasks/main.yml
@@ -0,0 +1,90 @@
+---
+- name: prepare /var/lib/kubelet as LVM
+ when: kubelet_lvm is defined
+ block:
+
+ - name: create logical volume
+ lvol:
+ vg: "{{ kubelet_lvm.vg }}"
+ lv: "{{ kubelet_lvm.lv }}"
+ size: "{{ kubelet_lvm.size }}"
+
+ - name: create filesystem
+ filesystem:
+ fstype: "{{ kubelet_lvm.fs }}"
+ dev: "/dev/mapper/{{ kubelet_lvm.vg | replace('-', '--') }}-{{ kubelet_lvm.lv | replace('-', '--') }}"
+
+ - name: mount filesytem
+ mount:
+ src: "/dev/mapper/{{ kubelet_lvm.vg | replace('-', '--') }}-{{ kubelet_lvm.lv | replace('-', '--') }}"
+ path: /var/lib/kubelet
+ fstype: "{{ kubelet_lvm.fs }}"
+ state: mounted
+
+- name: install apt https transport
+ apt:
+ name: apt-transport-https
+ state: present
+ force: yes
+
+- name: add kubernetes apt key
+ apt_key:
+ data: "{{ lookup('file', 'kubernetes-apt-key.asc') }}"
+ state: present
+
+- name: add kubernetes apt repo
+ apt_repository:
+ repo: deb http://apt.kubernetes.io/ kubernetes-xenial main
+ state: present
+ filename: kubernetes
+
+- name: install basic kubernetes components
+ with_items:
+ - "kubelet{% if kubernetes.pkg_version is defined %}={{ kubernetes.pkg_version }}{% endif %}"
+ - "kubeadm{% if kubernetes.pkg_version is defined %}={{ kubernetes.pkg_version }}{% endif %}"
+ - "kubectl{% if kubernetes.pkg_version is defined %}={{ kubernetes.pkg_version }}{% endif %}"
+ apt:
+ name: "{{ item }}"
+ state: present
+
+- name: disable automatic upgrades for kubernetes components
+ when: kubernetes.pkg_version is defined
+ with_items:
+ - kubelet
+ - kubeadm
+ - kubectl
+ dpkg_selections:
+ name: "{{ item }}"
+ selection: hold
+
+- name: install kubelet config snippets
+ with_items:
+ - 20-dns.conf
+ - 50-extra.conf
+ template:
+ src: "{{ item }}.j2"
+ dest: "/etc/systemd/system/kubelet.service.d/{{ item }}"
+ notify: reload systemd
+
+- name: add dummy group with gid 998
+ group:
+ name: app
+ gid: 998
+
+- name: add dummy user with uid 998
+ user:
+ name: app
+ uid: 998
+ group: app
+ password: "!"
+
+- name: add kubectl config for shells
+ with_items:
+ - zsh
+ - bash
+ blockinfile:
+ path: "/root/.{{ item }}rc"
+ create: yes
+ marker: "### {mark} ANSIBLE MANAGED BLOCK for kubectl ###"
+ content: |
+ source <(kubectl completion {{ item }})