概要
Ansibleを実行した際、以下のような警告が出力された場合の原因と対策。
[DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as it can also be a list of hosts, a directory or a list of paths . This feature
will be removed in version 2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
原因
ansible.cfg
に非推奨となっている hostfile
というオプションを設定していることが原因。
設定例:
hostfile = ./hosts
※インベントリーファイルを指定する(デフォルトの/etc/ansible/hosts以外のインベントリーファイルを使う)際のオプション
出力の通り、 Ansible version 2.8
では廃止されるオプションなので使うべきではない。
対策
hostfile
ではなく、 inventory
を使う。
設定例:
inventory = ./hosts
これで警告が出なくなる。
検証環境
ansibleのバージョン2.4.3.0で検証した。
この事象はバージョン1.9以降で発生する。
$ ansible --version
ansible 2.4.3.0