示例:

# 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选项共用

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2022-12-23
  • 2021-07-29
  • 2021-09-23
猜你喜欢
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2021-12-14
相关资源
相似解决方案