
Ansible:2.9 Windows:W2k16 伺服器
我正在尋找一種在遠端 Windows 主機中註冊(記錄)Ansible 操作的方法。
例如,當我使用win_command
命令模組時echo test
,我在 Windows 事件日誌中找不到引用此操作的行。
如何使 ansible 操作顯示在 Windows 事件日誌中?
答案1
我理解你喜歡問的問題登記並記錄傳回值從win_command
在 Windows 事件日誌中。
你可以使用win_eventlog_entry
– 將條目寫入 Windows 事件日誌和類似的東西
- name: Save the result of 'whoami' in 'result'
ansible.windows.win_command: whoami
register: result
- name: Write 'result.stdout' to Windows Event Log
community.windows.win_eventlog_entry:
log: Result of win_command
source: Ansible module win_command
event_id: 1234
message: "{{ result.stdout }}"