Skip to content

Instantly share code, notes, and snippets.

@mdiener21
Created January 5, 2021 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdiener21/70d85671f5a2c26d82ac1f162c3a3f33 to your computer and use it in GitHub Desktop.
Save mdiener21/70d85671f5a2c26d82ac1f162c3a3f33 to your computer and use it in GitHub Desktop.
Install Docker and Docker-Compose using Ansible
- hosts: all
become: yes
gather_facts: false
tasks:
- name: Install docker packages
remote_user: ubuntu
apt:
name: "{{ item }}"
state: present
update_cache: yes
with_items:
- apt-transport-https
- ca-certificates
- curl
- software-properties-common
tags:
- docker
- name: Add Docker s official GPG key
remote_user: ubuntu
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
tags:
- docker
- name: Verify that we have the key with the fingerprint
remote_user: ubuntu
apt_key:
id: 0EBFCD88
state: present
tags:
- docker
- name: Set up the stable repository
remote_user: ubuntu
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
state: present
update_cache: yes
tags:
- docker
- name: Update apt packages
remote_user: ubuntu
apt:
update_cache: yes
tags:
- docker
- name: Install docker
remote_user: ubuntu
apt:
name: docker-ce
state: present
update_cache: yes
#notify: Start docker on boot
tags:
- docker
- name: Add remote "ubuntu" user to "docker" group
remote_user: ubuntu
user:
name: "ubuntu"
group: "docker"
append: yes
tags:
- docker
- name: Install docker-compose
remote_user: ubuntu
get_url:
url : https://github.com/docker/compose/releases/download/1.25.1-rc1/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose
mode: 'u+x,g+x'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment