LoginSignup
3

More than 5 years have passed since last update.

Ansibleを使ってリモートホストにDockerをさくっとセットアップする

Posted at

あらまし

VPSで確保したリモートホストにDockerを入れようとしたが、
手順が面倒そうだったので、Ansible GalaxyのRoleを用いてインストールしてみた。

環境

さくらのVPSでインストールしたUbuntu 16.04 Server

手順

Ubuntu 16.04はデフォルトでPythonが入っていないようだ。

そのため、まずSSHでログインしてPythonをインストールしておく。

$ sudo apt-get install python

次に、以下の2つのファイルを用意する。

your-hostは対象とするホスト名またはIPアドレス。

hosts
your-host
install-docker.yml
- name: Run docker.ubuntu
  hosts: all
  roles:
    - angstwad.docker_ubuntu

以下のコマンドを実行する。
your-userは対象とするホストのユーザ名(この名前でSSHログインするようだ)。

$ ansible-galaxy install angstwad.docker_ubuntu
$ ansible-playbook -vvvv -i hosts install-docker.yml -u your-user -k -K -s

しばらく待つと、インストールが完了する。

参考

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3