'How to create dictionary object from one fact from each host
I am running ansible role to get package version on 50 servers. As example, I am looking to get output in form below
{
server1: "1.0",
server2: "1.0",
.
.
.
servert50: "1.1"
}
I have the logic to get the version but can't get a clear way to collect one fact from each run after role execution is finished.
The following didn't produce what I am looking for since it runs after each execution NOT once at the end. Also I need to have facts in list of dictionaries.
post_tasks:
- name: Print installed versions
run_once: true
copy:
content: "{{ hostvars | to_nice_json }}"
dest: /tmp/hostvar.json
delegate_to: localhost
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
