diff options
author | Romain Gonçalves <me@rgoncalves.se> | 2022-12-17 21:58:37 +0100 |
---|---|---|
committer | Romain Gonçalves <me@rgoncalves.se> | 2022-12-17 21:58:37 +0100 |
commit | 3c256ad4bc071685b35fe601fc5683a858914d80 (patch) | |
tree | 812fcd0a9bdd0fce6a66d6d3a31341245a4c90b9 /roles | |
parent | 322c53df835d24feda59fa287e4062c6e9f69480 (diff) | |
download | rules-3c256ad4bc071685b35fe601fc5683a858914d80.tar.gz |
refactor(roles/pf): modular test for open ports
Diffstat (limited to 'roles')
-rw-r--r-- | roles/pf/defaults/main.yml | 2 | ||||
-rw-r--r-- | roles/pf/handlers/main.yml | 6 | ||||
-rw-r--r-- | roles/pf/tasks/main.yml | 5 |
3 files changed, 8 insertions, 5 deletions
diff --git a/roles/pf/defaults/main.yml b/roles/pf/defaults/main.yml index 0523589..edba159 100644 --- a/roles/pf/defaults/main.yml +++ b/roles/pf/defaults/main.yml @@ -1,3 +1,5 @@ --- pf_configuration_file: /etc/pf.conf +pf_test_ports: + - "{{ ansible_port }}" diff --git a/roles/pf/handlers/main.yml b/roles/pf/handlers/main.yml index 85a0996..2d518eb 100644 --- a/roles/pf/handlers/main.yml +++ b/roles/pf/handlers/main.yml @@ -5,10 +5,10 @@ - name: enable pf ansible.builtin.command: pfctl -e - register: result + register: pf_result_enable failed_when: - - result.rc != 0 - - "'already enabled' not in result.stderr" + - pf_result_enable.result.rc != 0 + - "'already enabled' not in pf_result_enabled.result.stderr" - name: restart pf ansible.builtin.command: pfctl -f "{{ pf_configuration_file }}" diff --git a/roles/pf/tasks/main.yml b/roles/pf/tasks/main.yml index e90e348..8e81e1c 100644 --- a/roles/pf/tasks/main.yml +++ b/roles/pf/tasks/main.yml @@ -12,8 +12,9 @@ - enable pf - restart pf -- name: test ssh connection on new pf rule +- name: test pf rules ansible.builtin.wait_for: - port: "{{ ansible_port }}" + port: "{{ item }}" delay: 2 state: started + loop: "{{ pf_test_ports }}" |