从剧本中提取以前的内核和当前的内核



以下是获取当前内核详细信息、重新启动服务器,然后附加新内核的易操作手册,但没有按预期进行。它给出的内核版本与重新启动后相同:

- 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

关于如何在重新启动后在包含以前的内核的报告中附加当前内核的任何建议

您使用的变量(例如ansible_kernelansible_xxx…(是在游戏开始时默认自动收集的主机事实。如果您的计算机在重新启动后运行不同的内核,则需要再次收集要更新的事实。你可以把你的第二个csv任务放在你的剧本中的一个新剧本中,默认情况下会再次收集事实,也可以在重新启动后手动收集事实:

- name: refresh facts as the machine rebooted
setup:

最新更新