ansible-roles/apache/tasks/ip_whitelist.yml
David Prevot fc692cf65b
All checks were successful
gitea/ansible-roles/pipeline/head This commit looks good
Allow more --check runs
Use “when: not ansible_check_mode” or “when <file>.stat.exists or not
ansible_check_mode” in order to provide a meaningful diff if possible.

This is an improvement from the previously reverted commit
1728eaee68.
2022-12-21 18:05:41 +01:00

30 lines
737 B
YAML

---
- name: Is ipaddr_whitelist.conf present?
stat:
path: /etc/apache2/ipaddr_whitelist.conf
register: _ipaddr_whitelist_conf
- name: Add IP addresses to private IP whitelist
lineinfile:
dest: /etc/apache2/ipaddr_whitelist.conf
line: "Require ip {{ item }}"
state: present
loop: "{{ apache_ipaddr_whitelist_present }}"
notify: reload apache
tags:
- apache
- ips
when: _ipaddr_whitelist_conf.stat.exists or not ansible_check_mode
- name: Remove IP addresses from private IP whitelist
lineinfile:
dest: /etc/apache2/ipaddr_whitelist.conf
line: "Require ip {{ item }}"
state: absent
loop: "{{ apache_ipaddr_whitelist_absent }}"
notify: reload apache
tags:
- apache
- ips