From d8f01f8b08dc2d93d6f96c70d7697c5d79a162e6 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Tue, 11 Feb 2014 13:39:38 +0000 Subject: [PATCH] Fix escaping the '.' in the IPs using jinja2 directly and fix when to run what --- playbooks/denyhosts.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/playbooks/denyhosts.yml b/playbooks/denyhosts.yml index 5a8c9cb399..e033032228 100644 --- a/playbooks/denyhosts.yml +++ b/playbooks/denyhosts.yml @@ -26,26 +26,22 @@ vars: - test: True + - ip: "{{ ip |replace('.', '\\.') }}" tasks: - name: Grep for the IP in the files action: command grep {{ ip }} /etc/hosts.deny - when: not test - - - name: Escape the '.' in the IP - action: command "IP='{{ ip }}' && echo ${IP//\./\\.}" - register: ip when: test - name: Remove IP from /var/lib/denyhosts/* action: command sed -si "/^{{ ip }}$/d" /var/lib/denyhosts/* notify: - restart denyhosts - when: test + when: not test - name: Remove IP from /etc/hosts.deny action: command sed -si "/^{{ ip }}$/d" /etc/hosts.deny notify: - restart denyhosts - when: test + when: not test