One hosts file per cookbook

Hi
I use ansible in various environments and I don’t want to mix them up. My question is, is there a way to tell asnible to look in the playbook root directory for a hosts file instead of using only one hosts file and switching that using the environment variable? I also propose to have something like this for picking up the hosts file when running a playbook:

  • Look for it in the root directory of the project
  • Look a the ANSIBLE_HOSTS variable
  • Look at /etc/ansible/hosts
    This way I can also ship my hosts file with the project which is very convenient instead of having to keep everything in one hosts file or changing the environment variable.

ansible-playbook -i hostfile site.yml

works fine for me.

Thanks, Dick. I really would have deserved an “RTFM” here. It was right in the help of the command :slight_smile: