Browse Source

update docker

pull/22/head
fedy95 4 years ago
parent
commit
1101a7cf82
  1. 18
      roles/docker/tasks/main.yml
  2. 4
      roles/docker/vars/main.yml

18
roles/docker/tasks/main.yml

@ -1,5 +1,10 @@
--- ---
- name: Test if folder exist
stat:
path: "{{ docker_compose_bin }}"
register: docker_compose_bin_exist
- name: Update apt cache - name: Update apt cache
apt: apt:
update_cache: yes update_cache: yes
@ -7,6 +12,7 @@
- name: Upgrade all apt packages - name: Upgrade all apt packages
apt: upgrade=dist apt: upgrade=dist
when: docker_compose_bin_exist.stat.exists == False
- name: Install docker packages - name: Install docker packages
apt: apt:
@ -15,21 +21,25 @@
update_cache: yes update_cache: yes
cache_valid_time: "{{ aptcachetime }}" cache_valid_time: "{{ aptcachetime }}"
loop: ['apt-transport-https', 'ca-certificates', 'curl', 'gnupg-agent', 'software-properties-common'] loop: ['apt-transport-https', 'ca-certificates', 'curl', 'gnupg-agent', 'software-properties-common']
when: docker_compose_bin_exist.stat.exists == False
- name: Add Docker GPG key - name: Add Docker GPG key
apt_key: apt_key:
url: https://download.docker.com/linux/ubuntu/gpg url: https://download.docker.com/linux/ubuntu/gpg
state: present state: present
when: docker_compose_bin_exist.stat.exists == False
- name: Verify that we have the key with the fingerprint - name: Verify that we have the key with the fingerprint
apt_key: apt_key:
id: 0EBFCD88 id: 0EBFCD88
state: present state: present
when: docker_compose_bin_exist.stat.exists == False
- name: Add deb repository - name: Add deb repository
apt_repository: apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ lsb_release }} stable repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ lsb_release }} stable
state: present state: present
when: docker_compose_bin_exist.stat.exists == False
- name: Install docker - name: Install docker
apt: apt:
@ -38,22 +48,28 @@
update_cache: yes update_cache: yes
cache_valid_time: "{{ aptcachetime }}" cache_valid_time: "{{ aptcachetime }}"
loop: ['docker-ce', 'docker-ce-cli', 'containerd.io'] loop: ['docker-ce', 'docker-ce-cli', 'containerd.io']
when: docker_compose_bin_exist.stat.exists == False
- name: Create Docker group - name: Create Docker group
group: name=docker state=present group: name=docker state=present
when: docker_compose_bin_exist.stat.exists == False
- name: Add current user to Docker group - name: Add current user to Docker group
user: name="{{ ansible_env.USER }}" groups=docker append=yes user: name="{{ ansible_env.USER }}" groups=docker append=yes
when: docker_compose_bin_exist.stat.exists == False
- name: "Ensure Docker is {{ docker.start | ternary('started','stopped') }}" - name: "Ensure Docker is {{ docker.start | ternary('started','stopped') }}"
service: name=docker state={{ docker.start | ternary('restarted','stopped') }} enabled={{ docker.service_enabled }} service: name=docker state={{ docker.start | ternary('restarted','stopped') }} enabled={{ docker.service_enabled }}
when: docker_compose_bin_exist.stat.exists == False
- name: Install docker-compose - name: Install docker-compose
get_url: get_url:
url: https://github.com/docker/compose/releases/download/1.27.4/docker-compose-Linux-x86_64
url: https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose dest: /usr/local/bin/docker-compose
force: no force: no
mode: 0755 mode: 0755
when: docker_compose_bin_exist.stat.exists == False
- name: Upgrade installed packages - name: Upgrade installed packages
apt: upgrade=yes apt: upgrade=yes
when: docker_compose_bin_exist.stat.exists == False

4
roles/docker/vars/main.yml

@ -0,0 +1,4 @@
---
docker_compose_bin: "/usr/local/bin/docker-compose"
docker_compose_version: "1.27.4"