ansible debug msg выдает ошибку внутри обработчика

Playbook работает нормально, но модуль debug msg выдает ошибку undefined variable.

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

код в изображении для ясного понимания

1 ответ

Решение

Решается вызовом обеих задач в обработчиках с помощью 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"                       
Другие вопросы по тегам