Search code examples
ansibleansible-inventory

Ansible limit parameter is not working


I have my Ansible project structure like this:

enter image description here

My appServers under hosts contains my hosts as follows:

local ansible_ssh_host=127.0.0.1

staging ansible_ssh_host=<host_ip> ansible_connection=ssh  ansible_user=ubuntu  ansible_ssh_private_key_file=<key>

vara-dev ansible_ssh_host=<host ip> ansible_connection=ssh ansible_user=varanet ansible_ssh_pass=<password>

[localhost]
local

[iquippo-staging]
staging

[varanet-server]
vara-dev

[target]
local
staging
vara-dev

But when I am trying this command:

ansible -i inventory/hosts/ --limit local -m ping

It is throwing this error:

ERROR! Missing target hosts

I am using http://docs.ansible.com/ansible/intro_patterns.html for limit parameter.


Solution

  • You don't specify any host group for the command, so Ansible reports the required parameter is missing.

    See the result of:

    ansible all -i inventory/hosts/ --limit local -m ping