Write info about nodes to a CSV file on the controller (the local)

Viewed 9799

I have written an Ansible playbook that returns some information from various sources. One of the variables I am saving during a task is the number of records in a certain MySQL database table.

I can print out results in the playbook quite well. What I want to do however is write the results from all hosts in a single (csv) file on the master/control server or computer running the playbook

- name: Show results
  debug:
    msg: "URL: {{hostvars[inventory_hostname]['ansible_nodename']}} RECORDCOUNT: {{results.stdout}} BASE VERSION: {{baseversion.stdout}}"

This task prints the info I want for twenty nodes.
I now want to write this line in a single CSV file on the master server.

I've tried various things with local copy but until now to no avail.

2 Answers

This method has issues if the content is too long where your echo error's out. I ended up using the template module.

Just posting here as it may help someone else.

Related