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.
