Ansible: Store command's stdout in new variable?

前端 未结 6 652
暗喜
暗喜 2020-12-22 22:35

Inside my playbook I\'d like to create a variable holding the output of an external command. Afterwards I want to make use of that variable in a couple of templates.

6条回答
  •  萌比男神i
    2020-12-22 22:46

    There's no need to set a fact.

        - shell: cat "hello"
          register: cat_contents
    
        - shell: echo "I cat hello"
          when: cat_contents.stdout == "hello"
    

提交回复
热议问题