Ansible Pilot

Harnessing the Power of Ansible Uppercase Text Automation

Elevating Automation: Ansible Playbooks for Text Uppercasing using upper filter

January 4, 2024
Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons


In the ever-evolving landscape of IT automation, Ansible continues to be a go-to tool for simplifying and streamlining repetitive tasks. While traditionally known for its prowess in system configuration and infrastructure management, Ansible extends its capabilities to even the minutiae of text processing. In this article, we’ll explore a practical use case: automating the transformation of text to uppercase using an Ansible playbook.

The Uppercase Ansible Playbook

Below is an Ansible playbook named upper.yml designed to capitalize a given text and print the result on the screen.

- name: Uppercase
  hosts: all
  gather_facts: false
    my_text: "hello world"
    - name: Print message on the screen
        msg: "{{ my_text | upper }}"

Breaking down the playbook components:

The Inventory File

Ansible requires an inventory file to specify the hosts where the playbook will run. The inventory file in this example designates the localhost with the connection set to local, indicating that the playbook will be executed on the local machine.

localhost ansible_connection=local

The Best Resources For Ansible


Video Course

Printed Book


Executing the Playbook

Running the playbook is a straightforward process. The ansible-playbook command, coupled with the -i flag to specify the inventory file, is used:

$ ansible-playbook -i inventory upper.yml

Upon execution, Ansible processes the defined tasks and outputs the result:

PLAY [Uppercase] ************************************************************************

TASK [Print message on the screen] ******************************************************
ok: [localhost] => {
    "msg": "HELLO WORLD"

PLAY RECAP ******************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

The output confirms the successful execution of the playbook on the localhost host, resulting in the message “HELLO WORLD” being printed on the screen.

Customizing and Extending

This example illustrates the simplicity of leveraging Ansible for text manipulation tasks. To adapt the playbook for different text or sources, modify the my_text variable. Additionally, you can expand the playbook’s functionality to capitalize text from external files or dynamic inventories.


As demonstrated, Ansible is not only a powerhouse for system configurations but also a versatile tool for text processing automation. Whether you’re a system administrator, a DevOps professional, or anyone involved in IT operations, Ansible’s capabilities extend to tasks both large and small, showcasing its value in the realm of automation.

Subscribe to the YouTube channel, Medium, and Website, X (formerly Twitter) to not miss the next episode of the Ansible Pilot.


Learn the Ansible automation technology with some real-life examples in my

My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps

BUY the Complete PDF BOOK to easily Copy and Paste the 250+ Ansible code

Want to keep this project going? Please donate

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons
Follow me

Subscribe not to miss any new releases