Fix escaping the '.' in the IPs using jinja2 directly and fix when to run what
This commit is contained in:
parent
f458aec69e
commit
d8f01f8b08
1 changed files with 3 additions and 7 deletions
|
@ -26,26 +26,22 @@
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
- test: True
|
- test: True
|
||||||
|
- ip: "{{ ip |replace('.', '\\.') }}"
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Grep for the IP in the files
|
- name: Grep for the IP in the files
|
||||||
action: command grep {{ ip }} /etc/hosts.deny
|
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
|
when: test
|
||||||
|
|
||||||
- name: Remove IP from /var/lib/denyhosts/*
|
- name: Remove IP from /var/lib/denyhosts/*
|
||||||
action: command sed -si "/^{{ ip }}$/d" /var/lib/denyhosts/*
|
action: command sed -si "/^{{ ip }}$/d" /var/lib/denyhosts/*
|
||||||
notify:
|
notify:
|
||||||
- restart denyhosts
|
- restart denyhosts
|
||||||
when: test
|
when: not test
|
||||||
|
|
||||||
- name: Remove IP from /etc/hosts.deny
|
- name: Remove IP from /etc/hosts.deny
|
||||||
action: command sed -si "/^{{ ip }}$/d" /etc/hosts.deny
|
action: command sed -si "/^{{ ip }}$/d" /etc/hosts.deny
|
||||||
notify:
|
notify:
|
||||||
- restart denyhosts
|
- restart denyhosts
|
||||||
when: test
|
when: not test
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue