NewsBlur/ansible/roles/docker/tasks/install-Ubuntu.yml

88 lines
No EOL
2.7 KiB
YAML
Executable file

---
# tasks file for docker-ce-ansible-role
- name: Remove previous docker installation
become: yes
apt:
name: "{{ item.package }}"
state: absent
with_items: "{{ docker_cleanup_packages_Ubuntu }}"
- name: Install prerequisite packages
become: yes
apt:
name: "{{ item.package }}"
state: present
with_items: "{{ docker_prerequisite_packages_Ubuntu }}"
- name: Download Docker GPG key
become: yes
shell:
cmd: "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg"
creates: /usr/share/keyrings/docker-archive-keyring.gpg
- name: Set up the Docker repository with the correct GPG key
become: yes
ansible.builtin.apt_repository:
repo: "deb [arch={{ ansible_architecture }} signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
update_cache: yes
- name: Set up the Docker repository with the correct GPG key
become: yes
ansible.builtin.apt_repository:
repo: "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
update_cache: yes
- name: Set up the Docker repository with the correct GPG key
become: yes
ansible.builtin.apt_repository:
repo: "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
state: present
update_cache: yes
- name: Update APT cache
become: yes
ansible.builtin.apt:
update_cache: yes
- name: Install Docker CE
become: yes
apt:
name: docker-ce
state: present
update_cache: yes
- name: Check current docker-compose version
command: docker-compose --version
register: docker_compose_vsn
changed_when: false
failed_when: false
check_mode: no
tags: docker-compose
- set_fact:
docker_compose_current_version: "{{ docker_compose_vsn.stdout | regex_search('(\\d+(\\.\\d+)+)') }}"
when:
- docker_compose_vsn.stdout is defined
tags: docker-compose
- name: Docker compsoe current version
debug:
msg: "{{ docker_compose_current_version }}"
tags: docker-compose
- name: Install or upgrade docker-compose
become: yes
get_url:
url : "https://github.com/docker/compose/releases/download/v{{ 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 == ""
or docker_compose_current_version is version(docker_compose_version, '<')
tags: docker-compose