Tech Tutorial: Run Playbooks with Automation Content Navigator #
Introduction #
In this tutorial, we will delve into how to run Ansible playbooks using the Automation Content Navigator, a component integral to the Red Hat Ansible Automation Platform. The Automation Content Navigator provides a user-friendly interface to manage and execute your automation tasks efficiently. By the end of this tutorial, you will have a solid understanding of navigating the Automation Content Navigator and running Ansible playbooks specifically within a Red Hat environment.
Prerequisites #
- Access to a Red Hat Enterprise Linux (RHEL) system.
- Ansible and Automation Content Navigator installed on your machine. Ensure you have the latest version of Ansible installed, which is a part of the Red Hat Ansible Automation Platform.
- Basic knowledge of YAML and Ansible playbook structure.
Step-by-Step Guide #
Step 1: Setting Up Your Environment #
Before running any playbooks, ensure that your Ansible environment is correctly set up on your RHEL system. You can install Ansible via the Red Hat subscription by following these commands:
sudo subscription-manager repos --enable ansible-2.9-for-rhel-8-x86_64-rpms
sudo dnf install ansible
Ensure that the installation was successful by checking the Ansible version:
ansible --version
Step 2: Accessing Automation Content Navigator #
Automation Content Navigator is part of the Red Hat Ansible Automation Platform. To access it, navigate to the URL provided during the installation or setup process. This is typically in the format of https://<your-automation-platform-domain>
.
Step 3: Creating Your Playbook #
Before you can run a playbook, you need to create one. Here’s a simple example of an Ansible playbook that checks disk usage on your local machine. Create a file named check-disk.yml
:
---
- name: Check Disk Usage
hosts: localhost
tasks:
- name: Get disk usage
command: df -h
register: disk_usage
- name: Print disk usage
debug:
msg: "{{ disk_usage.stdout_lines }}"
Step 4: Uploading Your Playbook to Automation Content Navigator #
- Log into the Automation Content Navigator interface.
- Navigate to the “Projects” section and create a new project or select an existing one.
- In the project, find the option to add files and upload your
check-disk.yml
playbook.
Step 5: Running Your Playbook #
After uploading the playbook, follow these steps to run it:
- Go to the ‘Templates’ section and create a new job template.
- Select the project and the
check-disk.yml
playbook. - Specify the inventory; since our playbook runs on localhost, you can choose the default inventory.
- Save the template and then click on the “Launch” button to run the playbook.
Step 6: Monitoring Playbook Execution #
Once the playbook is running, you can monitor its execution in the “Jobs” section of the Automation Content Navigator. Here, you can view the status of the job, detailed execution logs, and any outputs or messages generated by the playbook.
Detailed Code Examples #
Below is an additional example of an Ansible Playbook that updates all packages on a RHEL system. This example assumes that you have administrative privileges on the host where you are running the playbook.
---
- name: Update All Packages on RHEL
hosts: all
become: yes
tasks:
- name: Ensure all packages are up to date
yum:
name: '*'
state: latest
Similarly, upload this playbook to the Automation Content Navigator following the steps outlined above and create a job template to run it.
Conclusion #
In this tutorial, you have learned how to set up your RHEL environment for Ansible, create playbooks, upload them to the Automation Content Navigator, and execute them. The Automation Content Navigator simplifies the process of managing and running Ansible playbooks, making it a valuable tool for any system administrator or DevOps professional working within the Red Hat ecosystem. With this knowledge, you can enhance your automation strategies and streamline your operational tasks.