ababup1192
2/19/2015 - 2:23 AM

AnsibleによるDocker環境の構築

AnsibleによるDocker環境の構築

[sandbox]
192.168.33.12
---
  - 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"

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