DevOps Classroom notes 19/Feb/2026

Storing output of one command using register

  • prompt: ansible register variable
  • yaml
- name: Example Playbook with register
  hosts: all
  tasks:
    - name: Check disk space
      ansible.builtin.command: df -h
      register: disk_space  # The output of this task is stored in a variable named 'disk_space'

    - name: Print disk space information
      ansible.builtin.debug:
        msg: "The disk space output is: {{ disk_space.stdout }}" # Accessing the 'stdout' attribute of the registered variable

  • stat module
  • Refer Here for the changes done to download tomcat only if /opt/tomcat/bin folder doesnot exist
  • In Ansible if we want to run a task only when something changed then we use handlers Refer Here
  • Generally ansible runs the handlers at the end, if we want to force it run to we use flush_handlers
give me flush_handlers example without meta and with meta
  • Refer Here for using handlers
  • Exercise: Create a similar playbook for installing tomcat 10 on redhat 10.

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube