Ajouter InstalleDocker.yml
This commit is contained in:
58
InstalleDocker.yml
Normal file
58
InstalleDocker.yml
Normal file
@@ -0,0 +1,58 @@
|
||||
---
|
||||
- name: Installer Docker sur les VMs
|
||||
hosts: all # ou spécifiez vos VMs
|
||||
become: yes
|
||||
|
||||
tasks:
|
||||
- name: Mettre à jour apt
|
||||
apt:
|
||||
update_cache: yes
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Installer les dépendances
|
||||
apt:
|
||||
name:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
- gnupg
|
||||
- lsb-release
|
||||
state: present
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Ajouter la clé GPG Docker
|
||||
apt_key:
|
||||
url: https://download.docker.com/linux/ubuntu/gpg
|
||||
state: present
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Ajouter le dépôt Docker
|
||||
apt_repository:
|
||||
repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
|
||||
state: present
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Installer Docker
|
||||
apt:
|
||||
name:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
- docker-compose-plugin
|
||||
state: present
|
||||
update_cache: yes
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Démarrer et activer Docker
|
||||
systemd:
|
||||
name: docker
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: Vérifier l'installation
|
||||
command: docker --version
|
||||
register: docker_version
|
||||
|
||||
- name: Afficher la version
|
||||
debug:
|
||||
msg: "Docker installé: {{ docker_version.stdout }}"
|
||||
Reference in New Issue
Block a user