AnsibleにDynamic Inventoryという機能があることを知った。Ansibleではインベントリという機能があり、適用先やグループ分けをファイルに書くことで適用するプレイブックを切り替えられる。しかし、これは静的なため、サーバーの台数が多いと管理が不便なこともある。Dynamic Inventoryを使えば動的に適用先を取得できるようだが、まだ試したことがなかったので、試してみる。 準備 まず、以下のようなサーバーを用意する。全てFloatingIPを付与していて、直接SSHできる。 +--------------------------------------+----------+--------+--------------------------------------+------------------------------------+-----------+