Installation de docker !

This commit is contained in:
William 2020-11-16 23:49:17 +01:00
parent 17b4c7976a
commit 68cc8a80a4
2 changed files with 49 additions and 4 deletions

View File

@ -1,2 +1,2 @@
[webservers] [webservers]
server.example.org ansible_user=me server.example.org ansible_user=ubuntu

View File

@ -1,5 +1,50 @@
- hosts: webservers ---
- name: Setup docker
hosts: webservers
become: yes
tasks: tasks:
- name: What is your hostname ? - name: Install required system packages
command: hostname apt:
name: [
'apt-transport-https',
'ca-certificates',
'curl',
'gnupg-agent',
'software-properties-common',
]
state: latest
update_cache: yes
- name: Add Docker GPG apt Key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu focal stable
state: present
- name: Update apt and install docker-ce
apt:
name: [
'docker-ce',
'docker-ce-cli',
'containerd.io',
]
state: latest
update_cache: yes
- name: Install docker-compose
get_url:
url : https://github.com/docker/compose/releases/download/1.27.4/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose
mode: 'u+x,g+x'
- name: Add user to docker group
user:
name: ubuntu
groups: docker
append: yes