LoginSignup
8
3

More than 5 years have passed since last update.

【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【ansible ver.2.4.3.0】

Last updated at Posted at 2018-03-21

概要

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