
Another major use of variables is running a command and using the result of that command to save the result into a variable
- hosts: all
tasks:
- name: Ansible register variable basic example
shell: "find *.txt"
args:
chdir: "/Users/mdtutorials2/Documents/Ansible"
register: find_output
- debug:
var: find_output
#
- hosts: all
tasks:
- name: Ansible register with_items example
shell: "find *.txt"
args:
chdir: "/Users/mdtutorials2/Documents/Ansible"
register: with_output
- shell: "cp {{ item }} {{item}}_bkp"
with_items:
- "{{ with_output.stdout_lines }}"
Latest posts by scmgalaxy K (see all)
- Use of runtime variables to save into another variable using register in Ansible - September 6, 2018
- Ansible & Ansible Tower Variable Precedence Hierarchy - September 6, 2018
- How to use template in Ansible? - September 6, 2018