forked from openstack-k8s-operators/edpm-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openstack-k8s-operators#513 from gibizer/libvirt-f…
…irewall-live-migration [edpm_libvirt]Open firewall for live migration traffic
- Loading branch information
Showing
5 changed files
with
71 additions
and
25 deletions.
There are no files selected for viewing
67 changes: 49 additions & 18 deletions
67
roles/edpm_libvirt/molecule/default/test-helpers/verify_firewall.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,70 @@ | ||
- name: libvirt rule source file exists | ||
become: true | ||
ansible.builtin.stat: | ||
path: "/var/lib/edpm-config/firewall/libvirt.yaml" | ||
register: libvirt_rule_source_exists | ||
- name: Assert libvirt rule source file exists | ||
ansible.builtin.assert: | ||
that: | ||
- libvirt_rule_source_exists.stat.exists | ||
fail_msg: "libvirt rule source file does not exist" | ||
|
||
- name: verify vnc nftables firewall rules | ||
block: | ||
- name: Check if nftables rule exists in /etc/nftables/edpm-rules.nft | ||
- name: Check if vnc nftables rule exists in /etc/nftables/edpm-rules.nft | ||
become: true | ||
ansible.builtin.shell: grep -q "005 Allow vnc access on all networks." /etc/nftables/edpm-rules.nft | ||
register: rule_exists | ||
- name: Assert nftables rule exists in /etc/nftables/edpm-rules.nft | ||
register: vnc_rule_exists | ||
- name: Assert vnc nftables rule exists in /etc/nftables/edpm-rules.nft | ||
ansible.builtin.assert: | ||
that: | ||
- rule_exists.rc == 0 | ||
- vnc_rule_exists.rc == 0 | ||
fail_msg: "vnc rule does not exist in /etc/nftables/edpm-rules.nft" | ||
- name: vnc rule port range and protocol | ||
become: true | ||
ansible.builtin.shell: grep -q "EDPM_INPUT tcp dport { 5900-6923 }" /etc/nftables/edpm-rules.nft | ||
register: rule_content_exists | ||
register: vnc_rule_content_exists | ||
- name: Assert vnc rule port range and protocol | ||
ansible.builtin.assert: | ||
that: | ||
- rule_content_exists.rc == 0 | ||
- vnc_rule_content_exists.rc == 0 | ||
fail_msg: "vnc rule port range and protocol incorrect in /etc/nftables/edpm-rules.nft" | ||
- name: vnc rule source file exists | ||
become: true | ||
ansible.builtin.stat: | ||
path: "/var/lib/edpm-config/firewall/vnc.yaml" | ||
register: rule_source_exists | ||
- name: Assert vnc rule source file exists | ||
ansible.builtin.assert: | ||
that: | ||
- rule_source_exists.stat.exists | ||
fail_msg: "vnc rule source file does not exist" | ||
- name: Run nft list command and grep for VNC rule in EDPM_INPUT chain | ||
become: true | ||
ansible.builtin.shell: nft list table inet filter | awk '/chain EDPM_INPUT {/,/}/' | grep vnc | ||
register: chain_exists | ||
register: vnc_chain_exists | ||
- name: Assert that output from greping for VNC contains the correct rule | ||
assert: | ||
that: | ||
- item | regex_search('\s+tcp dport 5900-6923 ct state new counter packets \d+ bytes \d+ accept comment\s+') | ||
loop: "{{ chain_exists.stdout_lines }}" | ||
loop: "{{ vnc_chain_exists.stdout_lines }}" | ||
|
||
- name: verify live migration nftables firewall rules | ||
block: | ||
- name: Check if migration nftables rule exists in /etc/nftables/edpm-rules.nft | ||
become: true | ||
ansible.builtin.shell: grep -q "006 Allow libvirt live migration traffic" /etc/nftables/edpm-rules.nft | ||
register: migration_rule_exists | ||
- name: Assert migration nftables rule exists in /etc/nftables/edpm-rules.nft | ||
ansible.builtin.assert: | ||
that: | ||
- migration_rule_exists.rc == 0 | ||
fail_msg: "migration rule does not exist in /etc/nftables/edpm-rules.nft" | ||
- name: migration rule port range and protocol | ||
become: true | ||
ansible.builtin.shell: grep -q "EDPM_INPUT tcp dport { 61152-61215 }" /etc/nftables/edpm-rules.nft | ||
register: migration_rule_content_exists | ||
- name: Assert migration rule port range and protocol | ||
ansible.builtin.assert: | ||
that: | ||
- migration_rule_content_exists.rc == 0 | ||
fail_msg: "migration rule port range and protocol incorrect in /etc/nftables/edpm-rules.nft" | ||
- name: Run nft list command and grep for migration rule in EDPM_INPUT chain | ||
become: true | ||
ansible.builtin.shell: nft list table inet filter | awk '/chain EDPM_INPUT {/,/}/' | grep migration | ||
register: migration_chain_exists | ||
- name: Assert that output from grepping for migration contains the correct rule | ||
assert: | ||
that: | ||
- item | regex_search('\s+tcp dport 61152-61215 ct state new counter packets \d+ bytes \d+ accept comment\s+') | ||
loop: "{{ migration_chain_exists.stdout_lines }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters