LoginSignup
5
6

More than 5 years have passed since last update.

Ansible 動作チェック用の Docker イメージ

Last updated at Posted at 2016-08-05

Ansible の動作チェック用の Docker イメージを作った。そのコンテナには、公開鍵の設定をすることなくパスワードなしで root ユーザーとして ssh できる。

注意

これは、Ansible 動作チェック専用のイメージであって、実運用を念頭に置いていない。セキュリティ関係の処理が簡略化されていることに注意すること。

準備するファイル

Dockerfile
FROM ubuntu:trusty
RUN export DEBIAN_FRONTEND=noninteractive \
  && apt-get update \
  && apt-get install -y python \
  && apt-get install -y software-properties-common \
  && apt-add-repository -y ppa:ansible/ansible \
  && apt-get update \
  && apt-get install -y ansible \
  && apt-get install -y openssh-server \
  && rm -rf /var/lib/apt/lists/*

# empty root password
RUN passwd -d root

# allow root to ssh without password
COPY sshd_config /etc/ssh/sshd_config
sshd_config
PermitEmptyPasswords yes
PasswordAuthentication yes
UsePAM no
# need sftp server to run Ansible
Subsystem sftp /usr/lib/openssh/sftp-server

イメージ作成

$ ls
Dockerfile sshd_config
$ docker build -t ubuntu_ansible .

コンテナ実行

$ docker run -it ubuntu_ansible
# service ssh start
# ifconfig eth0
=> IP アドレスを取得(例:173.17.0.2)
5
6
0

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
5
6