80 lines
1.9 KiB
YAML
80 lines
1.9 KiB
YAML
|
- name: Remove docker if installed from CentOS repo
|
||
|
yum:
|
||
|
name:
|
||
|
- docker
|
||
|
- docker-client
|
||
|
- docker-client-latest
|
||
|
- docker-common
|
||
|
- docker-latest
|
||
|
- docker-latest-logrotate
|
||
|
- docker-logrotate
|
||
|
- docker-engine
|
||
|
state: absent
|
||
|
|
||
|
- name: Install required pkgs
|
||
|
yum:
|
||
|
name:
|
||
|
- yum-utils
|
||
|
- device-mapper-persistent-data
|
||
|
- lvm2
|
||
|
state: latest
|
||
|
|
||
|
- name: Add Docker repo
|
||
|
get_url:
|
||
|
url: https://download.docker.com/linux/centos/docker-ce.repo
|
||
|
dest: /etc/yum.repos.d/docker-ce.repo
|
||
|
|
||
|
- name: Install Docker
|
||
|
yum:
|
||
|
name:
|
||
|
- docker-ce
|
||
|
- docker-ce-cli
|
||
|
- containerd.io
|
||
|
state: latest
|
||
|
|
||
|
# - name: Convert old images to new runtime
|
||
|
# shell:
|
||
|
# cmd: " grep -rl 'docker-runc' /var/lib/docker/containers/ | xargs sed -i 's/docker-runc/runc/g' "
|
||
|
# changed_when: false
|
||
|
# failed_when: false
|
||
|
|
||
|
- name: Start Docker service
|
||
|
service:
|
||
|
name: docker
|
||
|
state: started
|
||
|
enabled: yes
|
||
|
tags:
|
||
|
- service
|
||
|
- docker
|
||
|
|
||
|
- name: Check if /usr/local/bin/docker-compose exists.
|
||
|
stat:
|
||
|
path: /usr/local/bin/docker-compose
|
||
|
register: docker_compose_file
|
||
|
|
||
|
- name: Check current docker-compose version
|
||
|
shell:
|
||
|
cmd: /usr/local/bin/docker-compose --version | cut -d ' ' -f3 | sed 's/.$//'
|
||
|
register: docker_compose_vsn
|
||
|
changed_when: false
|
||
|
failed_when: false
|
||
|
args:
|
||
|
warn: no
|
||
|
when:
|
||
|
- docker_compose_file.stat.exists
|
||
|
|
||
|
- set_fact:
|
||
|
docker_compose_current_version: "{{ docker_compose_vsn.stdout }}"
|
||
|
when:
|
||
|
- docker_compose_vsn.stdout is defined and docker_compose_file.stat.exists
|
||
|
|
||
|
- name: Install or upgrade docker-compose
|
||
|
get_url:
|
||
|
url : "https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-x86_64"
|
||
|
dest: /usr/local/bin/docker-compose
|
||
|
mode: 'a+x'
|
||
|
force: yes
|
||
|
when: >
|
||
|
docker_compose_current_version is not defined
|
||
|
or docker_compose_current_version is version(docker_compose_latest, '<')
|