Skip to content

Instantly share code, notes, and snippets.

@ababup1192
Last active June 3, 2019 14:04
Show Gist options
  • Save ababup1192/bdd31c09db5d0d482c30 to your computer and use it in GitHub Desktop.
Save ababup1192/bdd31c09db5d0d482c30 to your computer and use it in GitHub Desktop.
AnsibleによるDocker環境の構築

Ansible Docker

Docker環境を構築するansible-playbook。Docker本体とfig(docker-composeが普及するまでの繋ぎ)も同時に導入する。 Ansible環境やSandboxがない場合は、↓のgistから環境構築。

Ansible: https://gist.github.com/ababup1192/c0c3892869de117bbe03

Docker環境の構築(Sandbox example)

# パスワードなしでsshできるようにしておく。
ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.33.12
# playbookの実行。
ansible-playbook -i sandbox docker-install.yml
---
- hosts: all
sudo: yes
tasks:
- name: update centos64 kernel
yum: name=device-mapper-event-libs state=present
- name: key import for docker-io
rpm_key: state=present key=http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
- name: install the docker-io rpm from a remote repo
yum: name=http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm state=present
- name: install the latest version of docker-io and required tools
yum: name={{ item }} state=latest
with_items:
- vim
- git
- device-mapper-event-libs
- docker-io
- name: enable and runnning the docker
service: name=docker state=running enabled=yes
- name: install fig
shell: sh -c "curl -L https://github.com/docker/fig/releases/download/1.0.1/fig-`uname -s`-`uname -m` > /usr/bin/fig; chmod +x /usr/bin/fig"
[sandbox]
192.168.33.12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment