create update

This commit is contained in:
Torma Kristóf 2020-10-03 01:13:05 +02:00
parent 560c18ccfd
commit 87ae6663cb
9 changed files with 39 additions and 137 deletions

15
hosts
View File

@ -1,8 +1,17 @@
[opensuse] [opensuse]
192.168.42.90 192.168.42.4
192.168.42.5
192.168.42.6
192.168.42.7
192.168.42.8
192.168.42.13
192.168.42.15
[debian] [debian]
192.168.42.42 192.168.42.16
192.168.42.17
192.168.42.18
[centos] [centos]
192.168.42.69 192.168.42.21

View File

@ -0,0 +1,5 @@
- name: Update packages using dnf
dnf:
name: "*"
state: latest
autoremove: yes

View File

@ -1,12 +0,0 @@
- name: docker status
service:
name: docker
state: started
enabled: true
- name: restart kubelet
service:
name: kubelet
daemon_reload: yes
state: restarted
enabled: true

View File

@ -1,77 +0,0 @@
- name: Install packages that allow apt to be used over HTTPS
apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- aptitude
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
- name: Add an apt signing key for Docker
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add apt repository for stable version
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
state: present
- name: Install docker and its dependecies
apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- docker-ce
- docker-ce-cli
- containerd.io
notify:
- docker status
- name: Add user to docker group
user:
name: "{{ ansible_user_id }}"
group: docker
- name: Remove swapfile from /etc/fstab
mount:
name: "{{ item }}"
fstype: swap
state: absent
with_items:
- swap
- none
- name: Disable swap
command: swapoff -a
when: ansible_swaptotal_mb > 0
- name: Add an apt signing key for Kubernetes
apt_key:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
state: present
- name: Adding apt repository for Kubernetes
apt_repository:
repo: deb https://apt.kubernetes.io/ kubernetes-xenial main
state: present
filename: kubernetes.list
- name: Install Kubernetes binaries
apt:
name: "{{ packages }}"
state: present
update_cache: yes
vars:
packages:
- kubelet
- kubeadm
- kubectl
notify:
- restart kubelet

View File

@ -0,0 +1,8 @@
- name: Update repository cache using apt
apt:
update_cache: yes
- name: Update packages using apt
apt:
upgrade: dist
autoremove: yes

View File

@ -1,32 +0,0 @@
- name: Initialize the Kubernetes cluster using kubeadm
command: kubeadm init --apiserver-advertise-address="{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
- name: Creates .kube directory
file:
path: /home/{{ ansible_user_id }}/.kube
state: directory
- name: Copy files needed for kubectl
copy:
remote_src: yes
src: /etc/kubernetes/admin.conf
dest: /home/{{ ansible_user_id }}/.kube/config
owner: "{{ ansible_user_id }}"
group: users
- name: Set up weave network
shell: export KUBECONFIG=/etc/kubernetes/admin.conf && export kubever=$(kubectl version | base64 | tr -d '\n') && kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$kubever"
register: weavenet_out
- name: Generate join command
command: kubeadm token create --print-join-command
register: kubernetes_join_command_result
- name: Set the kubeadm join command globally.
set_fact:
kubernetes_join_command: >
{{ kubernetes_join_command_result.stdout }}
when: kubernetes_join_command_result.stdout is defined
delegate_to: "{{ item }}"
delegate_facts: true
with_items: "{{ groups['all'] }}"

View File

@ -0,0 +1,5 @@
- name: Update packages using zypper
zypper:
name: '*'
state: latest
update_cache: yes

View File

@ -1,4 +0,0 @@
- name: Join node to Kubernetes master
shell: >
{{ kubernetes_join_command }}
creates=/etc/kubernetes/kubelet.conf

View File

@ -1,21 +1,21 @@
--- ---
- name: Apply common configuration to all nodes - name: Update openSUSE virtual machines
hosts: all hosts: opensuse
become: true become: true
roles: roles:
- common - opensuse
- name: Configure and deploy Kubernetes master - name: Update Debian and Ubuntu virtual machines
hosts: master hosts: debian
become: true become: true
roles: roles:
- master - debian
- name: Join workers to Kubernetes cluster - name: Update CentOS virtual machines
hosts: worker hosts: centos
become: true become: true
roles: roles:
- worker - centos