Below is the ansible playbook to fetch the current kernel details, reboot the server and then append the new kernel but it is not happening as expected. It is giving same kernel version which is after reboot:
- name: Header
lineinfile:
path: /tmp/summary.csv
line: "HOST,PREVIOUS_KERNEL,UPTIME,CURRENT_KERNEL"
create: yes
delegate_to: localhost
- name: Inventory
lineinfile:
path: /tmp/summary.csv
line: "{{ ansible_fqdn }},{{ ansible_kernel }},{{ ansible_uptime_seconds }}"
delegate_to: localhost
- name: reboot
reboot:
reboot_timeout: 300
- name:
lineinfile:
path: /tmp/summary.csv
line: "{{ ansible_fqdn }},{{ ansible_kernel }},{{ ansible_uptime_seconds }},{{ ansible_kernel }}"
delegate_to: localhost
ANY SUGGESTION HOW TO APPEND THE CURRENT KERNEL AFTER REBOOT IN THE REPORT WHICH CONTAINS PREVIOUS KERNEL