'Ansible: reduce to the variable from registers of each host

---
- hosts: all
  tasks:
  - name: Read the file
    command: cat the_file
    register: the_file

  - name: Reduce them
    set_fact:
      result: "{{ the_file.stdout }}"
      reduce: yes # magic option

When the_file in each host written as "a", "b", "c" respectively, is it possible to get the variable like ["a", "b", "c"] or "abc"?

Hosts are not connected by ssh each other, but only from the playbook running one.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source