ansible/rst/patterns.rst

67 lines
1.3 KiB
ReStructuredText
Raw Normal View History

.. _patterns:
2012-03-08 18:53:48 +00:00
The Inventory File, Patterns, and Groups
========================================
2012-03-07 16:35:18 +00:00
2012-03-08 18:36:47 +00:00
How to select hosts you wish to manage
.. seealso::
:doc:`examples`
Examples of basic commands
:doc:`playbooks`
Learning ansible's configuration management language
2012-03-08 18:53:48 +00:00
Inventory File Format
+++++++++++++++++++++
2012-03-08 18:36:47 +00:00
Ansible works against multiple systems in your infrastructure at the
same time. It does this by selecting portions of systems listed in Ansible's inventory file,
which defaults to /etc/ansible/hosts, and looks like this::
mail.example.com
[webservers]
foo.example.com
bar.example.com
[dbservers]
one.example.com
two.example.com
three.example.com
2012-03-08 18:53:48 +00:00
Selecting Targets
+++++++++++++++++
These patterns target all hosts in the inventory file::
all
*
2012-03-08 18:36:47 +00:00
2012-03-08 18:53:48 +00:00
It is also possible to address specific hosts::
2012-03-08 18:36:47 +00:00
one.example.com
one.example.com:two.example.com
The following patterns address one or more groups, which are denoted
with the bracket headers in the inventory file::
2012-03-08 18:36:47 +00:00
webservers
webservers:dbservers
Individual hosts, but not groups, can also be referenced using
wildcards::
2012-03-08 18:36:47 +00:00
*.example.com
*.com
2012-03-08 18:36:47 +00:00
2012-03-08 18:53:48 +00:00
It's also ok to mix wildcard patterns and groups at the same time::
2012-03-08 18:36:47 +00:00
one*.com:dbservers
2012-03-08 18:53:48 +00:00
NOTE: It is not possible to target a host not in the inventory file.
2012-03-08 18:36:47 +00:00