0
点赞
收藏
分享

微信扫一扫

自动化运维工具Ansible(7)注册变量

往往用于保存一个task任务的执行结果, 以便于debug时使用。或者将此次task任务的结果作为条件,去判断是否去执行其他task任务。注册变量在PlayBook中通过`register`关键字去实现。

[root@localhost home]# vim myplaybook3.yml
---
- name: install a package and print the result
hosts: webservers
remote_user: root
tasks:
- name: install nginx package
yum: name=nginx state=present
register: install_result
- name: print result
debug: var=install_result

运行

自动化运维工具Ansible(7)注册变量_centos7

对比

自动化运维工具Ansible(7)注册变量_centos7_02

举报

相关推荐

0 条评论