将可变内容写入Ansible文件

时间:2018-11-26 12:28:27

标签: file ansible var

我试图按照我不幸运的方式将可变内容写到文件中。

任务:

- 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"

我在尝试正确的方法吗?

1 个答案:

答案 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"