LoginSignup
5
3

More than 5 years have passed since last update.

Macにhomebrewでansibleをインストールした際の設定ファイル(ansible.cfg)に関して

Last updated at Posted at 2015-12-04

以前、以下の記事を書いた。
Macにhomebrewでansibleをインストールした際のインベントリファイル(inventory file)に関して

次に、設定ファイル(ansible.cfg)を触ってみたくなる。
ただ、こちらもどこに置かれるのか分からない。

対応方法

おそらく、'inventory file'のデフォルトの場所と同じことが想像できるので、書いてみる。

$ vi /usr/local/etc/ansible/ansible.cfg

hostfile=~/original_hosts

対象となるIPアドレスを記述

$ echo 192.168.30.11 > ~/original_hosts

ansible実行

$ ansible 192.168.30.11 -m ping                                
Error reading config file: 
File contains no section headers.
file: /usr/local/etc/ansible/ansible.cfg, line: 1
'hostfile=~/original_hosts\n'

何かがおかしいらしい。

解決方法

ansible.cfgの書き方など何も調べずに書くのはやはり良くない。
以下を追加。

$ vi /usr/local/etc/ansible/ansible.cfg
[default]                             
hostfile=~/original_hosts

ansibleを再実行

$ ansible 192.168.30.11 -m ping                                
192.168.111.111 | success >> {
    "changed": false,
    "ping": "pong"
}

無事に解決。

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