Ansible date variable

后端 未结 5 1686
醉酒成梦
醉酒成梦 2020-12-29 01:21

I\'m trying to learn how to use Ansible facts as variables, and I don\'t get it. When I run...

$ ansible localhost -m setup

...it lists all

5条回答
  •  清歌不尽
    2020-12-29 01:50

    The lookup module of ansible works fine for me. The yml is:

    - hosts: test
      vars:
        time: "{{ lookup('pipe', 'date -d \"1 day ago\" +\"%Y%m%d\"') }}"
    

    You can replace any command with date to get result of the command.

提交回复
热议问题