Learning Automation - Flags | Roei Amsalem Learning Automation - Flags | Roei Amsalem

Flags

Flags are command arguments you add to control how Ansible runs.

--limit

--limit allows you to filter targets, either by group or host.

If you run a command on all and apply --limit to a specific group, only that group is targeted.

If that group does not exist in the command context, it returns nothing.

Example:

ansible all -i inventory.ini -m cisco.ios.ios_command -a 'commands=["show ip int brief"]' --limit OSPFrouters


You can apply the same idea to playbooks:

ansible-playbook -i inventory.ini site.yml --limit OSPFrouters