5

Ansible v2.2.1.0

I want to gather Ansible facts about a remote host defined in my inv/remote_hosts file, which looks like this:

[remote-host-0]
10.22.123.234

[remote-host-1]
10.22.234.123

How do I run the setup command and tell it to gather facts for remote-host-0?

$ ansible ??? -m setup ???

If I simply do this:

$ ansible remote-host-0 -m setup

I get:

ERROR! Attempted to read "/path_to_my_ansible_dir/ansible//hosts" as YAML: Syntax Error while loading YAML.

It's looking for the wrong hosts file, and I get a YAML error.

techraf
  • 64,883
  • 27
  • 193
  • 198
Chris F
  • 14,337
  • 30
  • 94
  • 192

1 Answers1

5

You can specify an inventory file with the -i option:

ansible remote-host-0 -m setup -i inv/remote_hosts
techraf
  • 64,883
  • 27
  • 193
  • 198