Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be8c3f2ed9 |
No files matched your search
@@ -297,48 +297,7 @@
|
||||
changed_when: false
|
||||
failed_when: docker_verify_start_run.rc != 2
|
||||
|
||||
# Switching an input back to false removes that unit and script and leaves the other alone.
|
||||
- name: Verify that a unit is removed when its input is false
|
||||
hosts: all
|
||||
vars:
|
||||
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
|
||||
docker_keyring_checksum: "{{ docker_stub_key.stat.checksum }}"
|
||||
docker_repo_base_url: file:///srv/docker-stub-repo
|
||||
docker_users: [moleculeuser]
|
||||
docker_start_missed: false
|
||||
docker_stop_at_shutdown: true
|
||||
docker_stop_at_shutdown_timeout: 20
|
||||
tasks:
|
||||
- name: Stat the stand-in repository key
|
||||
ansible.builtin.stat:
|
||||
path: /srv/docker-stub-repo/docker.asc
|
||||
checksum_algorithm: sha256
|
||||
register: docker_stub_key
|
||||
|
||||
- name: Apply the role with the boot unit off
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
|
||||
- name: Stat the boot unit's files and the shutdown unit's script
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item }}"
|
||||
loop:
|
||||
- /usr/local/sbin/docker-start-missed
|
||||
- /etc/systemd/system/docker-start-missed.service
|
||||
- /usr/local/sbin/docker-stop-at-shutdown
|
||||
register: docker_verify_off
|
||||
|
||||
- name: The boot unit is gone and the shutdown unit is still there
|
||||
ansible.builtin.assert:
|
||||
that: docker_verify_off.results | map(attribute='stat.exists') | list == [false, false, true]
|
||||
quiet: true
|
||||
|
||||
- name: Apply the role again with both inputs on
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
vars:
|
||||
docker_start_missed: true
|
||||
|
||||
# Converge's daemon.json, read before the role runs below change it.
|
||||
- name: Verify the daemon settings
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
@@ -369,22 +328,26 @@
|
||||
- docker_verify_daemon_stat.stat.pw_name == 'root'
|
||||
quiet: true
|
||||
|
||||
# The stand-in docker.service runs for real, so a restart shows in its start time: a changed file with docker_daemon_restart false leaves
|
||||
# it alone, and with true restarts it.
|
||||
- name: Verify that dockerd restarts only when asked
|
||||
# The stand-in docker.service runs for real, so a restart shows in its start time. The first run turns the boot unit off and changes
|
||||
# daemon.json with docker_daemon_restart false: the unit goes, the other stays and dockerd keeps running. The second turns everything
|
||||
# back on with docker_daemon_restart true: the boot unit returns and dockerd restarts.
|
||||
- name: Verify the unit inputs and that dockerd restarts only when asked
|
||||
hosts: all
|
||||
vars:
|
||||
docker_gpg_url: file:///srv/docker-stub-repo/docker.asc
|
||||
docker_keyring_checksum: "{{ docker_stub_key.stat.checksum }}"
|
||||
docker_repo_base_url: file:///srv/docker-stub-repo
|
||||
docker_users: [moleculeuser]
|
||||
docker_start_missed: true
|
||||
docker_stop_at_shutdown: true
|
||||
docker_stop_at_shutdown_timeout: 20
|
||||
docker_log_driver: local
|
||||
docker_log_max_size: 10m
|
||||
docker_log_max_file: "3"
|
||||
docker_live_restore: true
|
||||
docker_verify_unit_paths:
|
||||
- /usr/local/sbin/docker-start-missed
|
||||
- /etc/systemd/system/docker-start-missed.service
|
||||
- /usr/local/sbin/docker-stop-at-shutdown
|
||||
tasks:
|
||||
- name: Stat the stand-in repository key
|
||||
ansible.builtin.stat:
|
||||
@@ -397,10 +360,11 @@
|
||||
register: docker_verify_before
|
||||
changed_when: false
|
||||
|
||||
- name: Apply a changed setting with docker_daemon_restart false
|
||||
- name: Apply the boot unit off and a changed setting with docker_daemon_restart false
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
vars:
|
||||
docker_start_missed: false
|
||||
docker_daemon_options: {max-concurrent-downloads: 5}
|
||||
docker_daemon_restart: false
|
||||
|
||||
@@ -409,10 +373,30 @@
|
||||
register: docker_verify_kept
|
||||
changed_when: false
|
||||
|
||||
- name: Apply another change with docker_daemon_restart true
|
||||
- name: Stat the boot unit's files and the shutdown unit's script
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item }}"
|
||||
loop: "{{ docker_verify_unit_paths }}"
|
||||
register: docker_verify_off
|
||||
|
||||
- name: Read daemon.json
|
||||
ansible.builtin.slurp:
|
||||
src: /etc/docker/daemon.json
|
||||
register: docker_verify_daemon_kept
|
||||
|
||||
- name: The boot unit is gone, the shutdown unit is still there, and the changed file left dockerd running
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- docker_verify_off.results | map(attribute='stat.exists') | list == [false, false, true]
|
||||
- (docker_verify_daemon_kept.content | b64decode | from_json)['max-concurrent-downloads'] == 5
|
||||
- docker_verify_kept.stdout == docker_verify_before.stdout
|
||||
quiet: true
|
||||
|
||||
- name: Apply both units on and another change with docker_daemon_restart true
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
vars:
|
||||
docker_start_missed: true
|
||||
docker_daemon_options: {max-concurrent-downloads: 6}
|
||||
docker_daemon_restart: true
|
||||
|
||||
@@ -421,17 +405,23 @@
|
||||
register: docker_verify_restarted
|
||||
changed_when: false
|
||||
|
||||
- name: Read daemon.json
|
||||
- name: Stat the unit files again
|
||||
ansible.builtin.stat:
|
||||
path: "{{ item }}"
|
||||
loop: "{{ docker_verify_unit_paths }}"
|
||||
register: docker_verify_on
|
||||
|
||||
- name: Read daemon.json again
|
||||
ansible.builtin.slurp:
|
||||
src: /etc/docker/daemon.json
|
||||
register: docker_verify_daemon_after
|
||||
|
||||
- name: The first change left dockerd alone and the second restarted it
|
||||
- name: Both units are back and the second change restarted dockerd
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- docker_verify_kept.stdout == docker_verify_before.stdout
|
||||
- docker_verify_restarted.stdout != docker_verify_kept.stdout
|
||||
- docker_verify_on.results | map(attribute='stat.exists') | unique | list == [true]
|
||||
- (docker_verify_daemon_after.content | b64decode | from_json)['max-concurrent-downloads'] == 6
|
||||
- docker_verify_restarted.stdout != docker_verify_kept.stdout
|
||||
quiet: true
|
||||
|
||||
# A key that does not match docker_keyring_checksum fails at the key download, so the source line and packages are untouched. It goes to a separate path, so
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
# Only runs that apply the role; the refusal cases are in verify.yml.
|
||||
- name: Converge with an SSH rule and service rules
|
||||
hosts: all
|
||||
# The role reads no facts; ufw_ssh_port defaults from ansible_port.
|
||||
gather_facts: false
|
||||
gather_facts: true
|
||||
roles:
|
||||
- role: mortis.kamino.ufw
|
||||
vars:
|
||||
@@ -18,15 +17,14 @@
|
||||
# no proto: both protocols, and the guard must cope with the key missing
|
||||
- {rule: allow, port: 9090, comment: metrics}
|
||||
|
||||
# The service_rules entry point. prepare.yml stored a stale rule for svc_a, stale rules for
|
||||
# svc_c and a rule of the removed service svc_d, so every pass here is a no-op after the
|
||||
# first one, purge included. svc_c purges after svc_a ran, so svc_a's stale rule surviving
|
||||
# proves a purge touches only its own owner.
|
||||
# The service_rules entry point. prepare.yml stored a stale rule for svc_c,
|
||||
# a rule of the removed service svc_d and a stale rule for svc_e, so every pass here
|
||||
# is a no-op after the first one, purge included.
|
||||
- name: Converge the rules of several services through the entry point
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Keep the stale rule of svc_a because purging is off
|
||||
- name: Two rules for svc_a
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.ufw
|
||||
tasks_from: service_rules
|
||||
@@ -35,16 +33,18 @@
|
||||
ufw_service_rules:
|
||||
- {rule: allow, port: 8001, proto: tcp, comment: alpha web}
|
||||
- {rule: allow, port: 8002, proto: udp, from: 10.1.0.0/16, comment: alpha dns}
|
||||
- {rule: allow, port: 8003, proto: tcp, comment: beta}
|
||||
# No comment and no proto: the tag alone, and both protocols.
|
||||
- {rule: deny, port: 8004}
|
||||
# A comment that mentions the SSH port on another port.
|
||||
- {rule: allow, port: 8022, proto: tcp, comment: forward to 22 here}
|
||||
- {rule: allow, port: 7201, proto: tcp, comment: epsilon}
|
||||
|
||||
# Of the stale rules, only 7001 and 7601 are single numeric ports; the SSH lookalike, the
|
||||
# rule with no port, the source-only rule and the range are kept as possible SSH paths.
|
||||
- name: Purge the stale rules of svc_c except those that may carry SSH
|
||||
- name: Two rules for svc_b, one without a comment
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.ufw
|
||||
tasks_from: service_rules
|
||||
vars:
|
||||
ufw_service_name: svc_b
|
||||
ufw_service_rules:
|
||||
- {rule: allow, port: 8003, proto: tcp, comment: beta}
|
||||
- {rule: deny, port: 8004}
|
||||
|
||||
- name: Keep one rule for svc_c and purge its stale rule
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.ufw
|
||||
tasks_from: service_rules
|
||||
@@ -53,8 +53,6 @@
|
||||
ufw_purge_stale: true
|
||||
ufw_service_rules:
|
||||
- {rule: allow, port: 7101, proto: tcp, comment: gamma}
|
||||
- {rule: allow, port: 7301, proto: tcp, comment: eta}
|
||||
- {rule: allow, port: 7602, proto: tcp, comment: desired}
|
||||
|
||||
- name: Remove svc_d, which deletes without ufw_purge_stale
|
||||
ansible.builtin.include_role:
|
||||
@@ -64,6 +62,50 @@
|
||||
ufw_service_name: svc_d
|
||||
ufw_service_state: absent
|
||||
|
||||
- name: Keep the stale rule of svc_e because purging is off
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.ufw
|
||||
tasks_from: service_rules
|
||||
vars:
|
||||
ufw_service_name: svc_e
|
||||
ufw_service_rules:
|
||||
- {rule: allow, port: 7201, proto: tcp, comment: epsilon}
|
||||
|
||||
- name: A comment that mentions the SSH port on another port
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.ufw
|
||||
tasks_from: service_rules
|
||||
vars:
|
||||
ufw_service_name: svc_g
|
||||
ufw_service_rules:
|
||||
- {rule: allow, port: 8022, proto: tcp, comment: forward to 22 here}
|
||||
|
||||
- name: Purge svc_h without touching its stale rule that looks like the SSH rule
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.ufw
|
||||
tasks_from: service_rules
|
||||
vars:
|
||||
ufw_service_name: svc_h
|
||||
ufw_purge_stale: true
|
||||
ufw_service_rules:
|
||||
- {rule: allow, port: 7301, proto: tcp, comment: eta}
|
||||
|
||||
- name: Purge svc_p but keep its stale rules that may carry SSH
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
# prepare.yml stored four stale rules for svc_p: a numeric port (deleted), and a rule
|
||||
# with no port, a source-only rule and a range, which are kept as possible SSH paths.
|
||||
- name: Keep one rule for svc_p and purge its stale rules
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.ufw
|
||||
tasks_from: service_rules
|
||||
vars:
|
||||
ufw_service_name: svc_p
|
||||
ufw_purge_stale: true
|
||||
ufw_service_rules:
|
||||
- {rule: allow, port: 7602, proto: tcp, comment: desired}
|
||||
|
||||
# The orphan_rules entry point. prepare.yml stored two rules of svc_o1, a rule of
|
||||
# svc_o2 that looks like the SSH rule, and a rule of svc_m. The managed owners below are
|
||||
# the ones used above plus svc_m (listed but never called), so svc_o1 and svc_o2 are
|
||||
@@ -76,9 +118,14 @@
|
||||
vars:
|
||||
ufw_converge_managed:
|
||||
- svc_a
|
||||
- svc_b
|
||||
- svc_c
|
||||
- svc_d
|
||||
- svc_e
|
||||
- svc_g
|
||||
- svc_h
|
||||
- svc_m
|
||||
- svc_p
|
||||
tasks:
|
||||
# The marker is written after the purge, so the expected counts are absolute on both
|
||||
# passes: svc_o1 holds 2 rules before the purge and 0 once the marker exists.
|
||||
@@ -91,6 +138,9 @@
|
||||
ansible.builtin.set_fact:
|
||||
ufw_conv_o1_initial: "{{ 0 if ufw_conv_marker.stat.exists else 2 }}"
|
||||
|
||||
- name: Assert it before the first case
|
||||
ansible.builtin.include_tasks: tasks/orphan_check.yml
|
||||
|
||||
- name: No managed owners given, purge requested
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.ufw
|
||||
@@ -98,6 +148,9 @@
|
||||
vars:
|
||||
ufw_purge_orphans: true
|
||||
|
||||
- name: Nothing was deleted without a list
|
||||
ansible.builtin.include_tasks: tasks/orphan_check.yml
|
||||
|
||||
- name: An empty list of managed owners, purge requested
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.ufw
|
||||
@@ -106,6 +159,9 @@
|
||||
ufw_managed_owners: []
|
||||
ufw_purge_orphans: true
|
||||
|
||||
- name: Nothing was deleted with an empty list
|
||||
ansible.builtin.include_tasks: tasks/orphan_check.yml
|
||||
|
||||
- name: Report the orphans only
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.ufw
|
||||
@@ -114,8 +170,7 @@
|
||||
ufw_managed_owners: "{{ ufw_converge_managed }}"
|
||||
ufw_purge_orphans: false
|
||||
|
||||
# The counts are absolute, so one check proves none of the three cases above deleted.
|
||||
- name: The cases without a purge deleted nothing
|
||||
- name: Reporting deleted nothing
|
||||
ansible.builtin.include_tasks: tasks/orphan_check.yml
|
||||
|
||||
- name: Purge the orphans
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
proto: tcp
|
||||
comment: replaced
|
||||
|
||||
# Owners svc_a, svc_c and svc_d keep rules in converge.yml that these entries are
|
||||
# not part of: a stale rule that is only reported, stale rules to purge, a rule of
|
||||
# a removed service.
|
||||
# Owners svc_c, svc_d and svc_e keep rules in converge.yml that these entries are
|
||||
# not part of: a stale rule to purge, a rule of a removed service, a stale rule
|
||||
# that is only reported.
|
||||
- name: Store tagged rules that are no longer wanted
|
||||
community.general.ufw:
|
||||
rule: allow
|
||||
@@ -56,10 +56,9 @@
|
||||
# svc_c: the old spec of a rule whose port changed (key of allow|7001|tcp||||in)
|
||||
- {port: 7001, comment: "ansible-ufw[svc_c:128c086248]: old"}
|
||||
- {port: 7002, comment: "ansible-ufw[svc_d:abcdef0123]: gone"}
|
||||
# svc_a: a stale rule kept because svc_a does not purge, while svc_c's purge runs
|
||||
- {port: 7003, comment: "ansible-ufw[svc_a:aaaaaaaaaa]: kept"}
|
||||
# svc_c: a stale rule that looks like an SSH rule, which a purge must skip
|
||||
- {port: 22, from: 10.9.0.0/16, comment: "ansible-ufw[svc_c:bbbbbbbbbb]: old"}
|
||||
- {port: 7003, comment: "ansible-ufw[svc_e:aaaaaaaaaa]: kept"}
|
||||
# svc_h: a stale rule that looks like an SSH rule, which a purge must skip
|
||||
- {port: 22, from: 10.9.0.0/16, comment: "ansible-ufw[svc_h:bbbbbbbbbb]: old"}
|
||||
# orphan_rules: svc_o1 and svc_o2 are never listed as managed owners in converge.yml.
|
||||
# svc_o2's rule looks like the SSH rule and must survive a purge; svc_m is managed
|
||||
# but its role is never called, so its rule must survive too.
|
||||
@@ -74,11 +73,11 @@
|
||||
- {from: 10.20.0.0/24, comment: "ansible-ufw[svc_o3:5555555552]: source only"}
|
||||
- {port: "20:30", comment: "ansible-ufw[svc_o3:5555555553]: range over 22"}
|
||||
- {name: OrphanOpenSSH, comment: "ansible-ufw[svc_o3:5555555554]: openssh profile"}
|
||||
# svc_c again: 7601 is stale and deleted by its purge, the other three are stale and
|
||||
# may carry SSH, so they stay.
|
||||
- {port: 7601, comment: "ansible-ufw[svc_c:6666666664]: stale numeric"}
|
||||
- {interface: wg0, direction: in, comment: "ansible-ufw[svc_c:6666666661]: no port"}
|
||||
- {from: 10.30.0.0/24, comment: "ansible-ufw[svc_c:6666666662]: source only"}
|
||||
- {port: "40:50", comment: "ansible-ufw[svc_c:6666666663]: range"}
|
||||
# service_rules purge of svc_p (converge.yml keeps only a rule for 7602): 7601 is stale
|
||||
# and deleted, the other three are stale and may carry SSH, so they stay.
|
||||
- {port: 7601, comment: "ansible-ufw[svc_p:6666666664]: stale numeric"}
|
||||
- {interface: wg0, direction: in, comment: "ansible-ufw[svc_p:6666666661]: no port"}
|
||||
- {from: 10.30.0.0/24, comment: "ansible-ufw[svc_p:6666666662]: source only"}
|
||||
- {port: "40:50", comment: "ansible-ufw[svc_p:6666666663]: range"}
|
||||
loop_control:
|
||||
loop_var: ufw_prepare_rule
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
# Included by converge.yml around the orphan_rules cases. The counts are absolute: svc_o1
|
||||
# holds ufw_conv_o1_want rules (default ufw_conv_o1_initial: 2 before the purge, 0 after),
|
||||
# and the tagged total is 20 plus those. The 20: svc_a 7 (six desired, one stale), svc_c 7
|
||||
# (three desired, four stale kept as possible SSH paths), svc_m 1, svc_o2 1, svc_o3 4 (kept
|
||||
# orphans that may carry SSH).
|
||||
# Included by converge.yml and verify.yml after each orphan_rules case. The counts are
|
||||
# absolute: svc_o1 holds ufw_conv_o1_want rules (default ufw_conv_o1_initial: 2 before the
|
||||
# purge, 0 after), and the tagged total is 20 plus those. The 20: svc_a 2, svc_b 2, svc_c 1,
|
||||
# svc_e 2, svc_g 1, svc_h 2, svc_m 1, svc_o2 1, svc_o3 4 (kept orphans that may carry SSH),
|
||||
# svc_p 4 (its desired rule and three kept stale rules).
|
||||
- name: Read the rules ufw would load
|
||||
ansible.builtin.command: ufw show added
|
||||
register: ufw_conv_added
|
||||
@@ -18,8 +18,8 @@
|
||||
- ufw_conv_added.stdout_lines | select('search', 'svc_o2:3333333333') | list | length == 1
|
||||
- ufw_conv_added.stdout_lines | select('search', 'svc_o3:555555555[1-4]') | list | length == 4
|
||||
- ufw_conv_added.stdout_lines | select('search', 'svc_m:4444444444') | list | length == 1
|
||||
- ufw_conv_added.stdout_lines | select('search', 'svc_c:666666666[123]') | list | length == 3
|
||||
- ufw_conv_added.stdout_lines | select('search', 'svc_c:6666666664') | list | length == 0
|
||||
- ufw_conv_added.stdout_lines | select('search', 'svc_p:666666666[123]') | list | length == 3
|
||||
- ufw_conv_added.stdout_lines | select('search', 'svc_p:6666666664') | list | length == 0
|
||||
- ufw_conv_added.stdout_lines | select('match', '^ufw ') | select('search', 'ansible-ufw') | list | length == 20 + ufw_conv_o1_count | int
|
||||
- ufw_conv_added.stdout_lines | select('match', '^ufw ') | reject('search', 'ansible-ufw') | list | length == 5
|
||||
fail_msg: "Unexpected rules after the orphan_rules case: {{ ufw_conv_added.stdout_lines }}"
|
||||
|
||||
@@ -306,6 +306,12 @@
|
||||
that: "'ufw_managed_owners must be a list of strings matching' in ufw_verify_failure"
|
||||
quiet: true
|
||||
|
||||
# Converge's last play purged svc_o1 (want 0); svc_o2, svc_m and the tagged total carry the proof.
|
||||
- name: Nothing was deleted after the invalid owner
|
||||
ansible.builtin.include_tasks: tasks/orphan_check.yml
|
||||
vars:
|
||||
ufw_conv_o1_want: 0
|
||||
|
||||
- name: Verify
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
@@ -379,12 +385,12 @@
|
||||
that:
|
||||
- ufw_verify_tagged | select('search', ufw_verify_svc_a_web) | list | length == 1
|
||||
- 'ufw_verify_tagged | select("search", "8002.*ansible-ufw\[svc_a:[0-9a-f]{10}\]: alpha dns") | list | length == 1'
|
||||
- 'ufw_verify_tagged | select("search", "8003.*ansible-ufw\[svc_a:[0-9a-f]{10}\]: beta") | list | length == 1'
|
||||
- 'ufw_verify_tagged | select("search", "8004.*ansible-ufw\[svc_a:[0-9a-f]{10}\]:.$") | list | length == 1'
|
||||
- 'ufw_verify_tagged | select("search", "7201.*ansible-ufw\[svc_a:[0-9a-f]{10}\]: epsilon") | list | length == 1'
|
||||
- 'ufw_verify_tagged | select("search", "8022/tcp comment .ansible-ufw\[svc_a:[0-9a-f]{10}\]: forward to 22 here") | list | length == 1'
|
||||
- 'ufw_verify_tagged | select("search", "8003.*ansible-ufw\[svc_b:[0-9a-f]{10}\]: beta") | list | length == 1'
|
||||
- 'ufw_verify_tagged | select("search", "8004.*ansible-ufw\[svc_b:[0-9a-f]{10}\]:.$") | list | length == 1'
|
||||
- 'ufw_verify_tagged | select("search", "7101.*ansible-ufw\[svc_c:[0-9a-f]{10}\]: gamma") | list | length == 1'
|
||||
- 'ufw_verify_tagged | select("search", "7301.*ansible-ufw\[svc_c:[0-9a-f]{10}\]: eta") | list | length == 1'
|
||||
- 'ufw_verify_tagged | select("search", "7201.*ansible-ufw\[svc_e:[0-9a-f]{10}\]: epsilon") | list | length == 1'
|
||||
- 'ufw_verify_tagged | select("search", "8022/tcp comment .ansible-ufw\[svc_g:[0-9a-f]{10}\]: forward to 22 here") | list | length == 1'
|
||||
- 'ufw_verify_tagged | select("search", "7301.*ansible-ufw\[svc_h:[0-9a-f]{10}\]: eta") | list | length == 1'
|
||||
quiet: true
|
||||
vars:
|
||||
ufw_verify_tagged: "{{ ufw_verify_added.stdout_lines | select('match', '^ufw ') | select('search', 'ansible-ufw') | list }}"
|
||||
@@ -396,14 +402,15 @@
|
||||
that:
|
||||
- ufw_verify_added.stdout_lines | select('search', 'svc_c:128c086248') | list | length == 0
|
||||
- ufw_verify_added.stdout_lines | select('search', 'svc_d:') | list | length == 0
|
||||
- ufw_verify_added.stdout_lines | select('search', '7003.*svc_a:aaaaaaaaaa') | list | length == 1
|
||||
- ufw_verify_added.stdout_lines | select('search', 'svc_c:bbbbbbbbbb') | list | length == 1
|
||||
- ufw_verify_added.stdout_lines | select('search', '7003.*svc_e:aaaaaaaaaa') | list | length == 1
|
||||
- ufw_verify_added.stdout_lines | select('search', 'svc_h:bbbbbbbbbb') | list | length == 1
|
||||
- ufw_verify_added.stdout_lines | select('search', 'ansible-ufw') | list | length == 20
|
||||
quiet: true
|
||||
|
||||
# Twenty tagged rules: svc_a 7 (six desired, one stale), svc_c 7 (three desired, four stale),
|
||||
# svc_m 1, the SSH lookalike of svc_o2 and four orphans of svc_o3. Both rules of svc_o1 and
|
||||
# the numeric stale rules of svc_c were deleted; the kept ones may carry SSH.
|
||||
# Twenty tagged rules: svc_a 2, svc_b 2, svc_c 1, svc_e 2, svc_g 1, svc_h 2, svc_m 1, the
|
||||
# SSH lookalike of svc_o2, four orphans of svc_o3 and four rules of svc_p (its desired
|
||||
# rule and three stale ones). Both rules of svc_o1 and the numeric stale rule of svc_p were
|
||||
# deleted; the kept ones may carry SSH.
|
||||
- name: Orphans were purged except those that may carry SSH, a managed owner kept its rule
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
@@ -419,12 +426,12 @@
|
||||
- name: The stale purge of service_rules kept the lines that may carry SSH
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ufw_verify_added.stdout_lines | select('search', 'svc_c:6666666664') | list | length == 0
|
||||
- ufw_verify_added.stdout_lines | select('search', 'svc_p:6666666664') | list | length == 0
|
||||
- ufw_verify_added.stdout_lines | select('search', '7601') | list | length == 0
|
||||
- ufw_verify_added.stdout_lines | select('search', 'wg0.*svc_c:6666666661') | list | length == 1
|
||||
- ufw_verify_added.stdout_lines | select('search', '10\.30\.0\.0/24.*svc_c:6666666662') | list | length == 1
|
||||
- ufw_verify_added.stdout_lines | select('search', '40:50.*svc_c:6666666663') | list | length == 1
|
||||
- 'ufw_verify_added.stdout_lines | select("search", "7602.*ansible-ufw\\[svc_c:[0-9a-f]{10}\\]: desired") | list | length == 1'
|
||||
- ufw_verify_added.stdout_lines | select('search', 'wg0.*svc_p:6666666661') | list | length == 1
|
||||
- ufw_verify_added.stdout_lines | select('search', '10\.30\.0\.0/24.*svc_p:6666666662') | list | length == 1
|
||||
- ufw_verify_added.stdout_lines | select('search', '40:50.*svc_p:6666666663') | list | length == 1
|
||||
- 'ufw_verify_added.stdout_lines | select("search", "7602.*ansible-ufw\\[svc_p:[0-9a-f]{10}\\]: desired") | list | length == 1'
|
||||
quiet: true
|
||||
|
||||
- name: No rejected input left a rule behind
|
||||
@@ -499,7 +506,7 @@
|
||||
ufw_service_rules:
|
||||
- {rule: allow, port: 7701, proto: tcp, comment: check mode}
|
||||
|
||||
- name: An absent call for svc_a, which holds seven rules
|
||||
- name: An absent call for svc_a, which holds two rules
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.ufw
|
||||
tasks_from: service_rules
|
||||
@@ -517,7 +524,7 @@
|
||||
- name: Check mode added and deleted nothing
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ufw_verify_chk_before.stdout_lines | select('search', 'svc_a:') | list | length == 7
|
||||
- ufw_verify_chk_before.stdout_lines | select('search', 'svc_a:') | list | length == 2
|
||||
- ufw_verify_chk_after.stdout_lines == ufw_verify_chk_before.stdout_lines
|
||||
- ufw_verify_chk_after.stdout_lines | select('search', 'svc_chk|7701') | list | length == 0
|
||||
quiet: true
|
||||
Reference in new issue
Block a user