Hello, all.
It’s been a long time since I posted here, so please forgive any posting faux pas.
I’ve created the following playboos:
Hello, all.
It’s been a long time since I posted here, so please forgive any posting faux pas.
I’ve created the following playboos:
Hello, all.
It's been a long time since I posted here, so please forgive any posting faux pas.
I've created the following playboos:
---
- name: report aws migrator
hosts: all
gather_facts: false
tasks:
- name: collect facts
shell:
cmd: facter -p fqdn processorcount memorysize_mb blockdevice_sda_size blockdevice_vda_size operatingsystem
operatingsystemrelease is_virtual processor0 --json
register: facter_output\- name: print output debug: msg: "\{\{ facter\_output\.stdout \}\}" \- local\_action: copy content="\{\{ facter\_output\.stdout \}\}"\. dest="/Users/dyioulos/Documents/prodrept\.txt"
The problem is with the output to file. Data are overwritten, and
information for only the last host the playbook is
run against is captured. Additionally, i have to put any character here (denoted by ^): - local_action: copy
content="{{ facter_output.stdout }}"^ dest="/Users/dyioulos/Documents/prodrept.txt" in order for the output to be in
json format. That extra character is also printed, including if I
use newline) is also printed.
Your help in soving this would be greatly appreciated.
Hello Dimitri,
to collect the output from all hosts please try the following approach:
- local_action:
module: copy
content: |
{% for host in ansible_play_hosts %}
{{ host }}
{{ hostvars[host]['facter_output']['stdout'] }}
{% endfor %}
dest: "/Users/dyioulos/Documents/prodrept.txt"
run_once: yes
Regards
Racke
That worked great; thank you so much!
Racke,
For my edification, might I ask exactly what your code does?
Thanks,
Dimitri
I’m not sure if I should create another post for this ask: forgive me if I should. As per Racke, here’s my playbook now, and it works great: