Hi, I later came to know about lieinfile module and wrote it using that. Thanks for your suggestion though.
- name: GATHER CURRENT VERSION IN DEVICE FACTS ios_facts: - lineinfile: path: ./output/output10.txt state: present line: - "Image upgrade is successful. Current version is {{ ansible_net_version }} for {{ inventory_hostname }}" when: ansible_net_version == upgrade_ios_version - lineinfile: path: ./output/output10.txt state: present line: - "Image upgrade not successful. Current version is {{ ansible_net_version }} for {{ inventory_hostname }}" when: ansible_net_version != upgrade_ios_version Regards, Vikram On Monday, 15 March, 2021 at 1:02:42 pm UTC+5:30 Abhijeet Kasurde wrote: > There are multiple ways to do this. Like Pushparaj suggested you can use > Jinja2 template and render variables. > > Other ways to do this can be - > > 1. Use JSON callback plugin and convert it CSV file like - > https://stackoverflow.com/questions/54855755/need-to-generate-csv-file-report-out-of-ansible-playbook-output-executed-in-chec > 2. Write your own callback plugin to create a CSV file. You can see > https://docs.ansible.com/ansible/latest/dev_guide/developing_plugins.html#callback-plugins > > for callback development. You may want to explore and modify > https://github.com/ansible-collections/ansible.posix/blob/main/plugins/callback/cgroup_perf_recap.py > > to match your needs. > > > > On Mon, Mar 15, 2021 at 12:30 PM Rajthecomputerguy <rajtheco...@gmail.com> > wrote: > >> write a Jinja2 template and render the variable values and get a html >> table output. >> >> On Mon, Mar 15, 2021 at 12:18 PM Vikram S <vikrams...@gmail.com> wrote: >> >>> I am writing a script for IOS upgrade in switches and script involves >>> multiple TASKS like checking copying image, settings boot statement, etc. >>> The final task would be to check if IOS upgrade was successful or not and >>> display it on screen. >>> >>> Mgmt wants only the output message for the final TASK (whether IOS >>> upgrade was succesful or not) to be saved in excel sheet or table. They >>> don't have the patience to go through the entire output shown by ansible >>> for the playbook. >>> >>> How do i automatically save the output shown by ansible for only the >>> above mentioned final TASK to a excel sheet/table? >>> >>> >>> Thanks, >>> >>> Vikram >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Ansible Project" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to ansible-proje...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/ansible-project/cc7108fc-9342-4ffc-87a5-04cc01e2c15cn%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/ansible-project/cc7108fc-9342-4ffc-87a5-04cc01e2c15cn%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> >> >> -- >> >> Thanks, >> >> Pushparaj G >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ansible Project" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to ansible-proje...@googlegroups.com. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/CAE5Yv1Q5hs__FqFA_Vu1ZGeqQSKPqrusFLzCX2po7HwRYGC98g%40mail.gmail.com >> >> <https://groups.google.com/d/msgid/ansible-project/CAE5Yv1Q5hs__FqFA_Vu1ZGeqQSKPqrusFLzCX2po7HwRYGC98g%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > Thanks, > Abhijeet Kasurde > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/27d6fed0-648b-498e-97dc-fd1b5d1a69b3n%40googlegroups.com.