generated from linux-system-roles/template
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the firewall role and the selinux role from the ha_cluster role
- Introduce ha_cluster_manage_firewall to use the firewall role to manage the high-availability service and the fence-virt port. ha_cluster_manage_firewall is set to true, by default. - Introduce ha_cluster_manage_selinux to use the selinux role to manage the ports in the high-availability service. Assign cluster_port_t to the high-availability service ports. ha_cluster_manage_selinux is set to true, by default. - Add the test check task tasks/check_firewall_selinux.yml for verify the ports status. - Add meta/collection-requirements.yml.
- Loading branch information
Showing
25 changed files
with
225 additions
and
56 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-License-Identifier: MIT | ||
collections: | ||
- fedora.linux_system_roles |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
- block: | ||
- name: Set the fence-virt/fence-agents port to _ha_cluster_selinux | ||
set_fact: | ||
_ha_cluster_selinux: | ||
- {'ports': '1229', 'proto': 'tcp', 'setype': 'cluster_port_t', | ||
'state': '{{ _state_value }}', 'local': 'true'} | ||
when: | ||
- ( | ||
'fence-virt' in ha_cluster_fence_agent_packages | ||
or | ||
'fence-virt' in ha_cluster_extra_packages | ||
or | ||
'fence-agents-all' in ha_cluster_fence_agent_packages | ||
or | ||
'fence-agents-all' in ha_cluster_extra_packages | ||
) | ||
|
||
- name: Get the high-availability tcp service ports | ||
shell: |- | ||
set -euo pipefail | ||
grep 'protocol="tcp"' /usr/lib/firewalld/services/high-availability.xml\ | ||
| sed -e "s#.*port=\"\(.*\)\"/>#\1#" | ||
register: __tcp_ports | ||
changed_when: false | ||
|
||
- name: Get the high-availability udp service ports | ||
shell: |- | ||
set -euo pipefail | ||
grep 'protocol="udp"' /usr/lib/firewalld/services/high-availability.xml\ | ||
| sed -e "s#.*port=\"\(.*\)\"/>#\1#" | ||
register: __udp_ports | ||
changed_when: false | ||
|
||
- name: Add the high-availability tcp service ports to _ha_cluster_selinux | ||
set_fact: | ||
_ha_cluster_selinux: "{{ _ha_cluster_selinux | d([]) + | ||
[{'ports': item, 'proto': 'tcp', 'setype': 'cluster_port_t', | ||
'state': _state_value, 'local': 'true'}] }}" | ||
loop: "{{ __tcp_ports.stdout.split('\n') }}" | ||
|
||
- name: Add the high-availability udp service ports to _ha_cluster_selinux | ||
set_fact: | ||
_ha_cluster_selinux: "{{ _ha_cluster_selinux + | ||
[{'ports': item, 'proto': 'udp', 'setype': 'cluster_port_t', | ||
'state': _state_value, 'local': 'true'}] }}" | ||
loop: "{{ __udp_ports.stdout.split('\n') }}" | ||
|
||
- name: Ensure the service and the ports status with the selinux role | ||
include_role: | ||
name: fedora.linux_system_roles.selinux | ||
vars: | ||
selinux_ports: "{{ _ha_cluster_selinux }}" | ||
vars: | ||
_state_value: "{{ ha_cluster_manage_selinux | | ||
ternary('present', 'absent') }}" |
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
- block: | ||
- name: Check firewall service status | ||
command: firewall-cmd --list-services | ||
register: _result | ||
failed_when: "'high-availability' not in _result.stdout" | ||
changed_when: false | ||
|
||
- name: Check firewall port status | ||
command: firewall-cmd --list-ports | ||
register: _result | ||
failed_when: "'1229/tcp' not in _result.stdout" | ||
changed_when: false | ||
when: ha_cluster_manage_firewall | d(true) | bool | ||
|
||
- block: | ||
- name: Check firewall service status | ||
command: firewall-cmd --list-services | ||
register: _result | ||
failed_when: "'high-availability' in _result.stdout" | ||
changed_when: false | ||
|
||
- name: Check firewall port status | ||
command: firewall-cmd --list-ports | ||
register: _result | ||
failed_when: "'1229/tcp' in _result.stdout" | ||
changed_when: false | ||
when: not ha_cluster_manage_firewall | d(true) | bool | ||
|
||
- name: Get associated selinux ports | ||
shell: |- | ||
set -euo pipefail | ||
grep 'port=' /usr/lib/firewalld/services/high-availability.xml \ | ||
| sed -e "s#.*port=\"\(.*\)\"/>#\1#" | sort | uniq | ||
register: __ports | ||
changed_when: false | ||
|
||
- name: Check associated selinux ports | ||
shell: |- | ||
set -euo pipefail | ||
sudo semanage port --list | grep cluster_port_t | grep "{{ item }}" | ||
loop: "{{ __ports.stdout.split('\n') }}" | ||
changed_when: false | ||
when: ha_cluster_manage_selinux | d(true) | bool | ||
|
||
- name: Check associated selinux ports | ||
shell: |- | ||
set -euo pipefail | ||
sudo semanage port --list | grep cluster_port_t | grep "{{ item }}" | ||
register: __result | ||
loop: "{{ __ports.stdout.split('\n') }}" | ||
changed_when: false | ||
failed_when: __result.rc == 0 | ||
when: not ha_cluster_manage_selinux | d(true) | bool |
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
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
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
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
Oops, something went wrong.