可调试调试消息在处理程序内引发错误

问题描述 投票:0回答:1

Playbook运行正常,但调试消息模块抛出未定义的变量错误。

---
- 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"

code in image for clear understanding

linux ansible devops ansible-2.x ansible-handlers
1个回答
0
投票

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

---
- 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"                       
© www.soinside.com 2019 - 2024. All rights reserved.