Bug 2041997 - docs: cannot run ansible against localhost - can only use "ansible_connection=local"
Summary: docs: cannot run ansible against localhost - can only use "ansible_connection...
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: doc-Release_Notes-8-en-US
Version: 8.6
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: 8.6
Assignee: Lucie Vařáková
QA Contact: RHEL DPM
Eliane Ramos Pereira
Depends On:
TreeView+ depends on / blocked
Reported: 2022-01-18 16:46 UTC by Rich Megginson
Modified: 2023-01-17 20:59 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: Known Issue
Doc Text:
.Unable to manage `localhost` by using the `localhost` hostname in the playbook or inventory With the inclusion of the `ansible-core 2.13` package in RHEL, if you are running Ansible on the same host you manage your nodes, you cannot do it by using the `localhost` hostname in your playbook or inventory. This happens because `ansible-core 2.13` uses the `python38` module, and many of the libraries are missing, for example, `blivet` for the `storage` role, `gobject` for the `network` role. To workaround this problem, if you are already using the `localhost` hostname in your playbook or inventory, you can add a connection, by using `ansible_connection=local`, or by creating an inventory file that lists `localhost` with the `ansible_connection=local` option. With that, you are able to manage resources on `localhost`. For more details, see the article link:https://access.redhat.com/solutions/6726561[RHEL System Roles playbooks fail when run on localhost].
Clone Of:
Last Closed: 2022-02-28 15:23:42 UTC
Type: Bug
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-108509 0 None None None 2022-01-18 16:57:09 UTC

Description Rich Megginson 2022-01-18 16:46:15 UTC
Description of problem:

With RHEL 8.6, and the ansible-core 2.12 included in RHEL, you cannot use ansible to manage localhost by using the hostname "localhost" in the playbook or inventory.  That is, if you are running ansible on the same system that you want to manage, doing something like this will not work:

- hosts: localhost

The problem is that ansible-core 2.12 uses the python38 module, and many of the libraries that we use are missing such as blivet for the storage role, gobject for network, and many, many more.

You must instead tell ansible to use a local connection for localhost e.g. in the inventory use `ansible_connection=local`, or use `ansible-playbook -c local`, when you want to manage resources on localhost.

There is no way to fix this in the code, we will need to add this to our release notes and our documentation for RHEL8.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:

Actual results:

Expected results:

Additional info:

Comment 2 Pavel Cahyna 2022-01-18 20:48:07 UTC
how to quickly compare behavior with implicit localhost and explicit inventory connecting to localhost:

diff -u <(ansible -vvv -a /bin/true -c local localhost ) <(ansible -vvv  -a /bin/true -c local -i, all )

Note You need to log in before you can comment on or make changes to this bug.