---
- hosts: servers
gather_facts: no
become: yes
tasks:
- apt:
name: apt-transport-https
- apt:
name: ca-certificates
- apt:
name: curl
- apt:
name: software-properties-common
- shell: "apt list --installed |grep docker-ce"
register: docker_ce_installed
ignore_errors: True
- when: docker_ce_installed|failed
block:
- shell: apt-key list Docker
register: apt_key_exists
- when: not apt_key_exists.stdout
shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg |apt-key add -
- shell: grep download.docker.com /etc/apt/sources.list
register: apt_source_docker_exists
ignore_errors: True
- when: apt_source_docker_exists|failed
shell: add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- apt:
update_cache: yes
- apt:
name: docker-ce
こんな感じかなあ…
参考にしました:
コメント