【发布时间】:2022-11-04 23:09:07
【问题描述】:
我正在尝试创建一个可用于查看某些系统详细信息的 csv 文件。其中一项是系统正常运行时间,以 unix 秒为单位。但在 os.csv 输出文件中,我希望将其视为天数,HH:MM:SS。
在我的 yaml 脚本下面:
---
- name: playbook query system and output to file
hosts: OEL7_systems
vars:
output_file: os.csv
tasks:
- block:
# For permisison setup.
- name: get current user
command: whoami
register: whoami
run_once: yes
- name: clean_file
copy:
dest: "{{ output_file }}"
content: 'hostname,distribution,version,release,uptime'
owner: "{{ whoami.stdout }}"
run_once: yes
- name: fill os information
lineinfile:
path: "{{ output_file }}"
line: "{{ ansible_hostname }},\
{{ ansible_distribution }},\
{{ ansible_distribution_version }},\
{{ ansible_distribution_release }},\
{{ ansible_uptime_seconds }}"
# Tries to prevent concurrent writes.
throttle: 1
delegate_to: localhost
任何帮助表示赞赏。
尝试了几次转换,但无法使其正常工作。
【问题讨论】: