Ansibleのコマンドをインストールして、サーバ定義を行いコマンドの実行を試してみる方法です。
インストール
pythonのパッケージとしてインストールする
$ sudo pip install ansible
virtualenvを使ってインストール
$ wget https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py
$ python get-pipsi.py
$ pipsi install ansible
サーバの定義
ansible.cfg
[defaults]
inventory=./hosts
hosts
各サーバのグループごとにIPアドレス(もしくはホスト名)を列挙する。サーバのIPは複数書くことができる。
[db]
192.168.0.10
[web]
192.168.0.20
192.168.0.21
実行
下記のコマンドで対象サーバに対して一斉にコマンドを実行できる
対象サーバにpingを実行
$ ansible web -m ping
# 対象サーバに任意のコマンドを実行
$ ansible web -m command -a uptime
# -m commandは省略できる
ansible web -a uptime
# rootで実行するときは--becomeか-bオプションを使う
ansible web --become -a "ls -al /root"
こちらもおススメ