Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ansible/ansible.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
author12-malak <73274076+12-malak@users.noreply.github.com>2022-10-10 07:03:03 +0300
committerGitHub <noreply@github.com>2022-10-10 07:03:03 +0300
commit8ecfb7c6d8384365cf34c893f6e6faad421f3bc3 (patch)
treeade650290be93b78274712f5ced29c6ebef038c9 /docs
parentad5d9843d651dd35287e2ad1ed0f57439e864e7e (diff)
Added code-block wrappers in implicit_localhost.rst (#79086)
Fixes #79031
Diffstat (limited to 'docs')
-rw-r--r--docs/docsite/rst/inventory/implicit_localhost.rst9
1 files changed, 7 insertions, 2 deletions
diff --git a/docs/docsite/rst/inventory/implicit_localhost.rst b/docs/docsite/rst/inventory/implicit_localhost.rst
index 2f065dc7b3b..ced98df8e1d 100644
--- a/docs/docsite/rst/inventory/implicit_localhost.rst
+++ b/docs/docsite/rst/inventory/implicit_localhost.rst
@@ -5,7 +5,9 @@
Implicit 'localhost'
====================
-When you try to reference a ``localhost`` and you don't have it defined in inventory, Ansible will create an implicit one for you.::
+When you try to reference a ``localhost`` and you don't have it defined in inventory, Ansible will create an implicit one for you.:
+
+.. code-block:: yaml
- hosts: all
tasks:
@@ -13,7 +15,9 @@ When you try to reference a ``localhost`` and you don't have it defined in inven
stat: path=/var/log/hosts/{{inventory_hostname}}.log
delegate_to: localhost
-In a case like this (or ``local_action``) when Ansible needs to contact a 'localhost' but you did not supply one, we create one for you. This host is defined with specific connection variables equivalent to this in an inventory::
+In a case like this (or ``local_action``) when Ansible needs to contact a 'localhost' but you did not supply one, we create one for you. This host is defined with specific connection variables equivalent to this in an inventory:
+
+.. code-block:: yaml
...
@@ -27,6 +31,7 @@ This ensures that the proper connection and Python are used to execute your task
You can override the built-in implicit version by creating a ``localhost`` host entry in your inventory. At that point, all implicit behaviors are ignored; the ``localhost`` in inventory is treated just like any other host. Group and host vars will apply, including connection vars, which includes the ``ansible_python_interpreter`` setting. This will also affect ``delegate_to: localhost`` and ``local_action``, the latter being an alias to the former.
.. note::
+
- This host is not targetable via any group, however it will use vars from ``host_vars`` and from the 'all' group.
- Implicit localhost does not appear in the ``hostvars`` magic variable unless demanded, such as by ``"{{ hostvars['localhost'] }}"``.
- The ``inventory_file`` and ``inventory_dir`` magic variables are not available for the implicit localhost as they are dependent on **each inventory host**.