1.

Explain Ansible register.

Answer»

ANSIBLE register is used to store the output from TASK execution in a VARIABLE. This is useful when we have different outputs from each remote host. The register VALUE is valid throughout the playbook execution so we can make use of set_fact to MANIPULATE the data and provide input to other tasks accordingly.

- hosts: all tasks:name: find all txt files in /home shell: "find /home -name *.txt" register: find_txt_filesdebug:var: find_txt_files

In the above example, we are searching for all .txt files in the remote host’s home folder and then capturing it in find_txt_files and displaying that variable.



Discussion

No Comment Found