ansible模塊debug


示例:

# Example that prints the loopback address and gateway for each host
- debug: msg="System {{ inventory_hostname }} has uuid {{ ansible_product_uuid }}"

- debug: msg="System {{ inventory_hostname }} has gateway {{ ansible_default_ipv4.gateway }}"
  when: ansible_default_ipv4.gateway is defined

- shell: /usr/bin/uptime
  register: result

- debug: var=result

- name: Display all variables/facts known for a host
  debug: var=hostvars[inventory_hostname]

 

說明:

ansible-doc debug

debug是ansible版本的print語句 可以輸出變量的內容或者隨意的字符串 利於playbook執行階段的調試

 

Options: (= is mandatory)(= 后面的參數是強制要有的)

- msg
  輸出定義好的meassage 如果沒有message 默認輸出Hello world!

- var
  輸出變量的內容 不可與msg選項共用


免責聲明!

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



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