ad-hoc: add documentation about pattern (#73303)

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/75783/head
Abhijeet Kasurde 3 years ago committed by GitHub
parent e2ad9f1c85
commit 6981237130
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -190,6 +190,12 @@ Facts represent discovered variables about a system. You can use facts to implem
You can also filter this output to display only certain facts, see the :ref:`ansible.builtin.setup <setup_module>` module documentation for details.
Patterns and ad-hoc commands
----------------------------
See the :ref:`patterns <intro_patterns>` documentation for details on all of the available options, including
how to limit using patterns in ad-hoc commands.
Now that you understand the basic elements of Ansible execution, you are ready to learn to automate repetitive tasks using :ref:`Ansible Playbooks <playbooks_intro>`.
.. seealso::

@ -142,6 +142,36 @@ You can specify a pattern as a regular expression by starting the pattern with `
~(web|db).*\.example\.com
Patterns and ad-hoc commands
----------------------------
You can change the behavior of the patterns defined in ad-hoc commands using command-line options.
You can also limit the hosts you target on a particular run with the ``--limit`` flag.
* Limit to one host
.. code-block:: bash
$ ansible -m [module] -a "[module options]" --limit "host1"
* Limit to multiple hosts
.. code-block:: bash
$ ansible -m [module] -a "[module options]" --limit "host1,host2"
* Negated limit. Note that single quotes MUST be used to prevent bash interpolation.
.. code-block:: bash
$ ansible -m [module] -a "[module options]" --limit 'all:!host1'
* Limit to host group
.. code-block:: bash
$ ansible -m [module] -a "[module options]" --limit 'group1'
Patterns and ansible-playbook flags
-----------------------------------

Loading…
Cancel
Save