我试图按照我不幸运的方式将可变内容写到文件中。
任务:
- name: Collect some information about rootvg space.
raw: "df -h |grep /$ |awk -F / '{print $4}' |awk '{print $1}' |cut -d - -f1 |/usr/bin/xargs sudo /usr/sbin/vgs --noheading"
register: res
- name: Send to local file
local_action: copy content="{{ res }}" dest="/tmp/rootvg_space.log"
我在尝试正确的方法吗?
答案 0 :(得分:1)
- name: Collect some information about rootvg space
shell: "df -h |grep /$ |awk -F / '{print $4}' |awk '{print $1}' |cut -d - -f1 |/usr/bin/xargs sudo /usr/sbin/vgs --noheading"
register: res
- name: Send to local file
local_action: copy content="{{ res.stdout }}" dest="/tmp/rootvg_space.log"