Integrating Ansible and Red Hat Enterprise Linux 8 Beta

November 16, 2018 by Adam Miller

Ansible-and-RHEL

Red Hat is proud to announce that Ansible supports managing Red Hat Enterprise Linux 8 Beta hosts. Before you can manage Red Hat Enterprise Linux 8 Beta nodes with Ansible 2.7, though, you need to set the appropriate python interpreter. Ansible allows you to manage a huge range of hosts and devices, from legacy systems to beta-release testing platforms, by working with both Python 2 and Python 3. However, with Ansible 2.7 managing Red Hat Enterprise Linux 8 Beta, you must define which Python to use. When Ansible 2.8 is released, we plan for Ansible to automatically discover the correct Python to use on Red Hat Enterprise Linux 8 Beta hosts.

Setting the Python interpreter on Red Hat Enterprise Linux 8 Beta managed nodes

You can define the python interpreter Ansible should use on your Red Hat Enterprise Linux 8 Beta nodes with an inventory host_var, a group_var, a play, or an ad-hoc command. You must do this on every Red Hat Enterprise Linux 8 node just as you would for any Python3 enabled host. To set the python interpreter in your inventory with a host_var:

[RHEL8hosts]
RHEL8.example.com ansible_python_interpreter=/usr/libexec/platform-python

This example directs Ansible to use the Red Hat Enterprise Linux 8 Platform Python, which is meant for systems-level tooling, rather than the standard python interpreter. Since Ansible will be automating systems-level tasks, this will be our target.

Once you’ve set the correct python interpreter, you can run Ansible to manage this Red Hat Enterprise Linux 8 Beta system:

ansible RHEL8hosts -m yum -a “name=bash state=installed”

In Ansible 2.8, Ansible will automatically discover the best ansible_python_interpreter definition, and you will not need to set the python interpreter like this.

Testing Red Hat Enterprise Linux 8 Beta as an Ansible control node

Ansible Engine does not support using a Red Hat Enterprise Linux 8 Beta system as a control node in a production setting. However, you may wish to test this scenario locally to prepare for the eventual Red Hat Enterprise Linux 8 GA release. Note that Red Hat Ansible Engine is planning to support Red Hat Enterprise Linux 8 upon Ansible Engine 2.8 GA release, but at this time we’ll be using the upstream Ansible open source project to test our Red Hat Enterprise Linux 8 Beta control node.

Do not use the system-level Red Hat Enterprise Linux 8 Platform Python for control node actions. Instead, install a user-level Python to run Ansible commands, roles, and playbooks from a Red Hat Enterprise Linux 8 Beta system. We recommend installing Python 3.6 from an Ansible Upstream Project package via PyPI.

On the Red Hat Enterprise Linux 8 Beta host you plan to test as a control node, run the following command either as root or with sudo permissions:

yum -y module install python36

This command installs the Python 3.6 AppStream, which allows you to operate on the same version of Python as Platform Python but in a user-facing context. This is important for long-term compatibility but also for the flexibility to modify our environment without impacting the core Red Hat Enterprise Linux 8 Beta Platform.

Once you have Python 3.6 installed, install Ansible as a non-root user (recommended for installing PyPI content).

pip3 install --user ansible

Confirm that your Ansible installation is working with a quick test on localhost, using your Red Hat Enterprise Linux 8 Beta machine as both the control node and a managed node:

ansible localhost -m setup -e ansible_python_interpreter=/usr/libexec/platform-python

This ad-hoc command sets the ansible_python_interpreter on your Red Hat Enterprise Linux 8 Beta control node. At this point you can run Ansible on your Red Hat Enterprise Linux 8 Beta system just as you normally would from a standard install using pip.

When testing a Red Hat Enterprise Linux 8 Beta system as an Ansible control node and running against localhost, you use two different Python executables: the Python 3.6 package with Ansible Engine and the Platform Python with the modules kicked off by your ad-hoc task or playbook.

What Next? Questions? Comments? Feedback?

The Ansible Open Source Community is adapting to the release of Red Hat Enterprise Linux 8 Beta in the open, just as we do with all changes in technology. If you have questions, comments, or feedback about Ansible + Red Hat Enterprise Linux 8 Beta or anything else that interests you, we’d love to hear from you.

#ansible on irc.freenode.net

Ansible Project Mailing list

 

Share:

Topics:
Ansible, Red Hat


 

Adam Miller

Adam Miller is a member of the Ansible Core Engineering team focusing on the Ansible Core runtime, Linux system administration automation, container orchestration integrations, and Information Security automation. Adam has completed his Bachelors of Science in Computer Science and Masters of Science in Information Assurance and Security, both from Sam Houston State University. He is a Red Hat Certified Engineer (Cert# 110-008-810), and an active member of the open source community with a running history of contributions to the Ansible and Fedora Projects.


rss-icon  RSS Feed

Ansible Tower by Red Hat
Learn About Ansible Tower