Ubuntu 16.04 に Docker CE をインストールする Ansible Playbook

投稿者: ytyng 6 年 前
---
- 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

こんな感じかなあ…

参考にしました:

UbuntuにDocker CEをインストールする - Qiita

現在未評価

コメント

アーカイブ

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011