From 6adb0298497833e7a5524a062637284bc9c7326b Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 17 Oct 2022 14:10:13 +0200 Subject: [PATCH] Add role docker --- docker/files/docker-compose | 2 ++ docker/handlers/main.yml | 4 ++++ docker/tasks/main.yml | 40 +++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100755 docker/files/docker-compose create mode 100644 docker/handlers/main.yml create mode 100644 docker/tasks/main.yml diff --git a/docker/files/docker-compose b/docker/files/docker-compose new file mode 100755 index 0000000..4665469 --- /dev/null +++ b/docker/files/docker-compose @@ -0,0 +1,2 @@ +#!/bin/sh +docker compose $@ diff --git a/docker/handlers/main.yml b/docker/handlers/main.yml new file mode 100644 index 0000000..271f0b0 --- /dev/null +++ b/docker/handlers/main.yml @@ -0,0 +1,4 @@ +- name: restart_docker + service: + name: "docker" + state: restarted diff --git a/docker/tasks/main.yml b/docker/tasks/main.yml new file mode 100644 index 0000000..0c970fb --- /dev/null +++ b/docker/tasks/main.yml @@ -0,0 +1,40 @@ +#- name: Check if docker is already installed +# stat: +# path: /usr/bin/docker +# register: docker_file + +- name: Install Packages +# when: docker_file.stat.exists == False + package: + name: + - gpg + - gpg-agent + +- name: Add docker-key + apt_key: + url: https://download.docker.com/linux/debian/gpg + state: present + +- name: Add docker-repository + apt_repository: + repo: "deb https://download.docker.com/linux/{{ ansible_facts.distribution | lower }} {{ ansible_facts.distribution_release }} stable" + state: present + filename: docker + update_cache: yes + +- name: Install docker + package: + name: + - docker-ce + - docker-ce-cli + - containerd.io + - docker-compose-plugin + - pass + state: latest + +- name: Deploy docker-compose command to new docker compose plugin + ansible.builtin.copy: + src: docker-compose + dest: "/usr/local/bin/docker-compose" + mode: preserve +