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