-
Notifications
You must be signed in to change notification settings - Fork 19
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 cockpit role
- Introduce cockpit_manage_firewall to use the firewall role to manage the cockpit service. Default to false - means the firewall role is not used. - Introduce cockpit_manage_selinux to use the selinux role to manage the ports in the cockpit service. Assign websm_port_t to the cockpit service ports. Default to false - means the selinux role is not used. - Add the test check task tasks/check_firewall_selinux.yml for verify the ports status. - Add meta/collection-requirements.yml.
- Loading branch information
Showing
14 changed files
with
151 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
- name: Ensure the cockpit service is enabled | ||
include_role: | ||
name: fedora.linux_system_roles.firewall | ||
vars: | ||
_cockpit_port: "{{ cockpit_port if cockpit_port is defined else 9090 }}" | ||
_cockpit_port_proto: "{{ _cockpit_port }}/tcp" | ||
firewall: "{{ [{'service': 'cockpit', 'state': 'enabled'}] | ||
if (_cockpit_port | int) == 9090 else | ||
[{'port': _cockpit_port_proto, 'state': 'enabled'}] }}" | ||
when: | ||
- cockpit_manage_firewall | bool | ||
- ansible_facts['os_family'] == 'RedHat' |
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,13 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
- name: Ensure the service and the ports status with the selinux role | ||
include_role: | ||
name: fedora.linux_system_roles.selinux | ||
vars: | ||
_cockpit_port: "{{ cockpit_port if cockpit_port is defined else 9090 }}" | ||
selinux_ports: "{{ [{'ports': _cockpit_port, 'proto': 'tcp', | ||
'setype': 'websm_port_t', | ||
'state': 'present', 'local': 'true'}] }}" | ||
when: | ||
- cockpit_manage_selinux | bool | ||
- ansible_facts['os_family'] == 'RedHat' |
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,33 @@ | ||
# SPDX-License-Identifier: MIT | ||
--- | ||
- block: | ||
- block: | ||
- name: Check firewall port status when cockpit_manage_firewall is true | ||
command: firewall-cmd --list-service | ||
register: _result | ||
failed_when: "'cockpit' not in _result.stdout" | ||
changed_when: false | ||
when: | ||
- _cockpit_port | int == 9090 | ||
|
||
- name: Check firewall port status when cockpit_manage_firewall is true | ||
command: firewall-cmd --list-port | ||
register: _result | ||
failed_when: "'{{ _cockpit_port }}/tcp' not in _result.stdout" | ||
changed_when: false | ||
when: | ||
- _cockpit_port | int != 9090 | ||
when: | ||
- cockpit_manage_firewall | bool | ||
|
||
- name: Check associated selinux ports when cockpit_manage_selinux is true | ||
shell: |- | ||
set -euo pipefail | ||
semanage port --list -C | egrep "websm_port_t *tcp" | \ | ||
grep "{{ _cockpit_port }}" | ||
changed_when: false | ||
when: cockpit_manage_selinux | bool | ||
vars: | ||
_cockpit_port: "{{ cockpit_port if cockpit_port is defined else 9090 }}" | ||
when: | ||
- ansible_facts['os_family'] == 'RedHat' |
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