Add playbook to remove someone from denyhosts
This commit is contained in:
parent
a289418698
commit
c6cbf75e92
1 changed files with 45 additions and 0 deletions
45
playbooks/denyhosts.yml
Normal file
45
playbooks/denyhosts.yml
Normal file
|
@ -0,0 +1,45 @@
|
|||
# requires --extra-vars="target=somevhost ip=10.0.0.1 test={True,False}"
|
||||
|
||||
#General overview:
|
||||
# host provided via ``target`` argument on the CLI
|
||||
# IP provided via ``ip`` argument on the CLI
|
||||
# test provided via ``test`` argument on the CLI
|
||||
|
||||
# Log onto $target
|
||||
# if test is True:
|
||||
# grep on /etc/hosts.deny for the provided $ip
|
||||
# else:
|
||||
# escape the '.' in the $ip
|
||||
# remove $ip from /var/lib/denyhosts/*
|
||||
# remove $ip from /etc/hosts.deny
|
||||
# restart denyhosts
|
||||
|
||||
# sop: http://infrastructure.fedoraproject.org/infra/docs/denyhosts.txt
|
||||
|
||||
- name: Unban an IP from denyhosts
|
||||
hosts: $target
|
||||
user: root
|
||||
gather_facts: False
|
||||
|
||||
tasks:
|
||||
- name: Grep for the IP in the files
|
||||
action: command grep $ip /etc/hosts.deny
|
||||
only_if: '$test or not is_set($test)'
|
||||
|
||||
- name: Escape the '.' in the IP
|
||||
action: command ${$ip//\./\\.}
|
||||
register: ip
|
||||
only_if: '$test or not is_set($test)'
|
||||
|
||||
- name: Remove IP from /var/lib/denyhosts/*
|
||||
action: command sed -si "/^$ip$/d" /var/lib/denyhosts/*
|
||||
notify:
|
||||
- restart denyhosts
|
||||
only_if: 'is_set($test) and $test == False'
|
||||
|
||||
- name: Remove IP from /etc/hosts.deny
|
||||
action: command sed -si "/^$ip$/d" /etc/hosts.deny
|
||||
notify:
|
||||
- restart denyhosts
|
||||
only_if: 'is_set($test) and $test == False'
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue