ansible scripts done to install kubewrnetes prequesites
This commit is contained in:
74
ansible/playbooks/roles/containerd/tasks/main.yml
Normal file
74
ansible/playbooks/roles/containerd/tasks/main.yml
Normal file
@@ -0,0 +1,74 @@
|
||||
---
|
||||
# tasks file for containerd
|
||||
- name: Install containerd dependencies
|
||||
become: true
|
||||
ansible.builtin.package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop:
|
||||
"{{ containerd_dependencies }}"
|
||||
|
||||
- name: Install via apt
|
||||
become: true
|
||||
when: ansible_os_family == "Debian"
|
||||
block:
|
||||
- name: Add repo using key from URL (apt)
|
||||
ansible.builtin.deb822_repository:
|
||||
name: docker
|
||||
types: deb
|
||||
uris: https://download.docker.com/linux/ubuntu
|
||||
suites: "{{ ansible_distribution_release }}"
|
||||
components: stable
|
||||
architectures: amd64
|
||||
signed_by: https://download.docker.com/linux/ubuntu/gpg
|
||||
|
||||
- name: Update apt cache
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
|
||||
- name: Install via dnf
|
||||
become: true
|
||||
when: ansible_os_family == "RedHat"
|
||||
block:
|
||||
- name: Add repo using key from URL (dnf)
|
||||
ansible.builtin.yum_repository:
|
||||
name: docker
|
||||
description: "Docker repository"
|
||||
baseurl: https://download.docker.com/linux/ubuntu
|
||||
gpgcheck: true
|
||||
gpgkey: https://download.docker.com/linux/ubuntu/gpg
|
||||
|
||||
- name: Update dnf cache
|
||||
ansible.builtin.dnf:
|
||||
update_cache: true
|
||||
|
||||
- name: Install containerd
|
||||
become: true
|
||||
ansible.builtin.package:
|
||||
name: containerd.io
|
||||
state: present
|
||||
|
||||
- name: Create containerd config directory
|
||||
ansible.builtin.file:
|
||||
path: /etc/containerd
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
|
||||
- name: Check if containerd config file exists
|
||||
ansible.builtin.stat:
|
||||
path: /etc/containerd/config.toml
|
||||
register: containerd_config_file
|
||||
|
||||
- name: Generate default containerd config and enable SystemdCgroup
|
||||
when: containerd_config_file.stat.exists == false
|
||||
ansible.builtin.shell: |
|
||||
containerd config default > /etc/containerd/config.toml
|
||||
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
|
||||
|
||||
- name: Restart and enable containerd service
|
||||
ansible.builtin.systemd:
|
||||
name: containerd
|
||||
state: restarted
|
||||
enabled: true
|
||||
Reference in New Issue
Block a user