2019-03-09 21:54:44 +01:00
|
|
|
---
|
|
|
|
|
2019-12-09 18:53:37 +01:00
|
|
|
- name: Ensure python-dnf is installed
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.package:
|
2019-12-09 18:53:37 +01:00
|
|
|
name: "{{ 'python-dnf' if ansible_python_version is version_compare('3.0.0', '<') else 'python3-dnf' }}"
|
|
|
|
state: present
|
|
|
|
register: ensure_python_dnf_installed
|
2020-05-20 19:50:58 +02:00
|
|
|
become: "{{ k3s_become_for_package_install | ternary(true, false, k3s_become_for_all) }}"
|
2019-12-09 18:53:37 +01:00
|
|
|
until: ensure_python_dnf_installed is succeeded
|
|
|
|
retries: 3
|
|
|
|
delay: 10
|
|
|
|
when: ansible_pkg_mgr == 'dnf'
|
|
|
|
|
2019-03-09 21:54:44 +01:00
|
|
|
- name: Ensure Docker prerequisites are installed
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.yum:
|
2019-03-09 21:54:44 +01:00
|
|
|
name:
|
|
|
|
- yum-utils
|
|
|
|
- device-mapper-persistent-data
|
|
|
|
- lvm2
|
|
|
|
state: present
|
|
|
|
register: ensure_docker_prerequisites_installed
|
|
|
|
until: ensure_docker_prerequisites_installed is succeeded
|
|
|
|
retries: 3
|
|
|
|
delay: 10
|
2020-05-20 19:50:58 +02:00
|
|
|
become: "{{ k3s_become_for_package_install | ternary(true, false, k3s_become_for_all) }}"
|
2019-03-09 21:54:44 +01:00
|
|
|
|
2019-12-09 14:53:42 +01:00
|
|
|
- name: Check to see if Docker repository is available for this distribution
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.uri:
|
2019-12-09 14:53:42 +01:00
|
|
|
url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/{{ ansible_distribution_major_version }}"
|
|
|
|
register: k3s_redhat_repo_check
|
|
|
|
failed_when: false
|
|
|
|
changed_when: false
|
|
|
|
|
2019-03-09 21:54:44 +01:00
|
|
|
- name: Ensure Docker repository is installed and configured
|
2020-12-12 15:27:59 +01:00
|
|
|
ansible.builtin.yum_repository:
|
2019-03-09 21:54:44 +01:00
|
|
|
name: docker-ce
|
|
|
|
description: Docker CE Repository
|
|
|
|
baseurl: https://download.docker.com/linux/{{ ansible_distribution | lower }}/{{ ansible_distribution_major_version }}/$basearch/stable
|
|
|
|
gpgkey: https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg
|
|
|
|
enabled: true
|
|
|
|
gpgcheck: true
|
|
|
|
state: present
|
2021-02-16 16:46:01 +01:00
|
|
|
when:
|
|
|
|
- ansible_distribution | lower not in ['amazon']
|
|
|
|
- k3s_redhat_repo_check.status == 200
|
2020-05-20 19:50:58 +02:00
|
|
|
become: "{{ k3s_become_for_package_install | ternary(true, false, k3s_become_for_all) }}"
|
2019-12-09 14:53:42 +01:00
|
|
|
|
|
|
|
- name: Ensure Docker repository is installed and configured from file
|
2020-12-21 20:14:52 +01:00
|
|
|
ansible.builtin.command: yum-config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
|
2019-12-09 14:53:42 +01:00
|
|
|
args:
|
|
|
|
creates: /etc/yum.repos.d/docker-ce.repo
|
2021-02-16 16:46:01 +01:00
|
|
|
when:
|
|
|
|
- ansible_distribution | lower not in ['amazon']
|
|
|
|
- k3s_redhat_repo_check.status != 200
|
2020-05-20 19:50:58 +02:00
|
|
|
become: "{{ k3s_become_for_package_install | ternary(true, false, k3s_become_for_all) }}"
|