0

Playbook 运行良好,但调试 msg 模块抛出未定义变量错误。

---
- hosts: labservers
 become: yes
 tasks:
- name: restart httpd
 service:
     name: httpd
     state: restarted
 notify:
     - cmds
 handlers:
- name: change file details
replace:
    path: /etc/httpd/conf/magic
    regexp: 'its is nothing'
    replace: '100 notes ashes'
register: httpd_data
- name: commands out
debug:
    msg: "{{httpd_data}}"
listen: "cmds"

图像中的代码以便于理解

4

1 回答 1

0

通过使用listen调用处理程序中的两个任务来解决。

---
- hosts: labservers
become: yes
tasks:
- name: restart httpd
service:
     name: httpd
     state: restarted
notify:
     - cmds
handlers:
- name: change file details
replace:
    path: /etc/httpd/conf/magic
    regexp: '100 notes ashes'
    replace: '100 akash'
register: httpd_data
listen: "cmds"
- name: debug details
debug:
     msg:"{{ httpd_data }}"
listen: "cmds"                       
于 2020-04-28T23:05:07.383 回答