'Ansible Job Slicing works, but how to combine the playbook results
I have a playbook runs against multiple hosts, gathers some information, and stores it locally in a csv (hostname.csv). It then combines all the *.csv into Final.csv and emails it out from localhost. Works fine when not using Job Slicing. It also works using Job Slicing, but if it is say 3 slices I get 3 emails. I know this is due to each node executing the play against it's slice. I can not figure out how to, in the playbook, get all 3 Final.csv combined from all 3 nodes into 1 Final_Final.csv and email it out.
### Merge .csvs ###
- name: Merge (once) ALL .csv files in the localhost random directory "{{localhost_temp_path}}"
shell: awk 'FNR==1 && NR!=1{next;}{print}' "{{localhost_temp_path}}/"*.csv > "{{localhost_temp_path}}/{{ALL_script_outputs}}"
delegate_to: localhost
register: final_output
run_once: yes
### END Merge .csvs ###
### mail stuff ###
- name: send report by email
mail:
host: "{{mail_server}}"
port: 25
subject: "{{SUR_Report_Name}}"
body: "{{SUR_Report_Name}} attached"
attach: "{{localhost_temp_path}}/{{ALL_script_outputs}}"
from: "{{mail_from}}"
to: "{{SUR_Recipient_Email_Address}}"
charset: utf8
when: SUR_Recipient_Email_Address is defined
delegate_to: localhost
run_once: true
### end mail stuff ###
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
