ansible变量注册
当我们给被管理节点安装了某个服务,不晓得有没有安装正确,的情况下 就可以使用register变量注册的方法,来返回被管理节点的服务信息。
register:
实例:给被管理节点安装httpd服务,并且通过shell命令 ps aux | grep httpd 返回httpd安装的信息,先看分析
代码:
[root@localhost opt]# vi 6.yml
- hosts: dbserver
tasks:
- name: install httpd server
yum: name=httpd state=present
- name: service httpd server
service: name=httpd state=started
- name: check httpd server
shell: ps aux | grep httpd
register: check_httpd
- name: output variables
debug