I'm trying to use OS based variables for a handler but it doesn't work.
templates/iptables.j2 dest={{ iptables_config_file }} owner=root group=root mode=0644
notify:
- restart {{ iptables_service_name }}
tags:
- test
roles/common/handlers/main.yml
- name: restart iptables-persistent
service: name={{ iptables_service_name }} state=restarted
The output when I launch the playbook:
GATHERING FACTS ***************************************************************
ok: [172.16.100.211]
172.16.100.211: importing /etc/ansible/vars/Debian.yml
TASK: [common | test value] ***************************************************
ok: [172.16.100.211] => {
"item": "",
"msg": "iptables-persistent is the name of the service"
}
TASK: [common | IPv4 firewall configuration] **********************************
changed: [172.16.100.211] => {"changed": true, "dest":
"/etc/iptables/rules.v4", "gid": 0, "group": "root", "item": "",
"md5sum": "db47b56591cd1636563d51eeccb4c9e2", "mode": "0644", "owner":
"root", "size": 700, "src":
"/root/.ansible/tmp/ansible-1390201288.3-106768121935641/source",
"state": "file", "uid": 0}
ERROR: change handler (restart {{iptables_service_name}}) is not defined
In the task test value, the iptables_service_name is OK. But when I try to use it with my handler it doesn't work.
Can somebody tell me what I'm doing wrong?
Regards,