ansible command模塊將返回值寫入變量


ansible 中command模塊支持 register參數將遠程命令執行的輸出結果存儲在變量中,后續可以在when中對該變量進行檢索確定下一步任務。

---
- name: cat /etc/redhat-release
  command: cat /etc/redhat-release
  register: output

- name: Your linux is CentOS
  command: echo "CentOS"
  when: output.stdout.find('CentOS') != -1

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM