Ansible 1.5.21:debug 模块

1.5.21:debug 模块

官方文档:https://docs.ansible.com/ansible/latest/collections/ansible/builtin/debug_module.html#ansible-collections-ansible-builtin-debug-module

debug模块用于在Ansible执行playbook过程中输出相应的状态信息,检查变量赋值或表达式结果是否正确。

1.5.21.1:常用参数
参数说明
msg定义需要打印的信息;如不指定,打印的是“Hello World!"。
var定义要打印的变量名;和msg参数互斥。
1.5.21.2:示例

定义playbook,在playbook执行过程中打印目标主机名以及它的IP地址:

[root@ansible ~]# vim debug.yml
---
- hosts: centos
  tasks:
  - name: debug module test
    debug:
      msg: IpAddr of Host {{ ansible_nodename }} is {{ ansible_default_ipv4.address }}

执行playbook:

[root@ansible ~]# ansible-playbook debug.yml 

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-kSZsZTzX-1619503429548)(…/…/…/999%20Reserve/Typora%20Images/image-20210427122257984.png)]

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值