LoginSignup
8
7

More than 5 years have passed since last update.

Docker + Ansible で Hello World!

Last updated at Posted at 2016-08-05

Ansible 動作チェック用の Docker イメージ を使って、Ansible で Hello World! してみる。

用意するコンテナ

Control Machine(構成管理をする側)

$ docker run -it --name control_machine ubuntu_ansible

Managed Node(構成管理をされる側)

$ docker run -it --name managed_node ubuntu_ansible
# service ssh start
# ifconfig eth0
=> IP アドレスを取得(例:173.17.0.3)

用意するファイル

control_machine の適当なディレクトリに以下の2つのファイルを用意。

hosts
[managed_node]
172.17.0.3
setup.yml
---
- name: Hello Ansible
  hosts: managed_node
  user: root

  tasks:
    - name: Hello server
      shell: date >> now.txt

Ansible 実行

control_machine で

$ ls
hosts setup.yml
$ ansible-playbook ./setup.yml -v -vvvv -u root -i ./hosts
=> (実行結果が表示される)

結果確認

managed_node で

$ cat /root/now.txt
Thu Aug  4 23:43:41 UTC 2016

参考

Ansible "Hello world"

Ansible Documentation

8
7
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
8
7