Create a file with a name ip.txt
.
add you IPs which you want to block them to this file. Just one IP per line.
Add this block to your task file.
- name: block IP with iptables
iptables:
chain: INPUT
source: '{{ item }}'
jump: DROP
with_lines:
- "cat ~/ansible/ip.txt"