Skip to content

Commit

Permalink
add 'local' parameter to seport
Browse files Browse the repository at this point in the history
`community.general.seport` has recently added the `local` parameter
which is now supported by the role.

- `local: true`:
  * `state: present` enforces change to be made even though the
    port mapping could already exists in built in policy
  * `state: absent` would remove only local modification and would not
    try to remove builtin mapping.
  • Loading branch information
bachradsusi authored and richm committed Sep 13, 2022
1 parent db49725 commit 1e7aeed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Individual modifications can be dropped by setting `state` to `absent`.

```yaml
selinux_ports:
- { ports: '22100', proto: 'tcp', setype: 'ssh_port_t', state: 'present' }
- { ports: '22100', proto: 'tcp', setype: 'ssh_port_t', state: 'present', local: true }
```

#### run restorecon on filesystem trees
Expand Down
1 change: 1 addition & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
proto: "{{ item.proto | default('tcp') }}"
setype: "{{ item.setype }}"
state: "{{ item.state | default('present') }}"
local: "{{ item.local | default(False) }}"
with_items: "{{ selinux_ports }}"

- name: Set linux user to SELinux user mapping
Expand Down
8 changes: 8 additions & 0 deletions tests/tests_port.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
selinux_ports:
- { ports: '22022', proto: 'tcp', setype: 'ssh_port_t',
state: 'present' }
- { ports: '22023', proto: 'tcp', setype: 'ssh_port_t',
state: 'present', local: true }

- name: include test variables
import_tasks: set_selinux_variables.yml
Expand All @@ -51,6 +53,12 @@
selinux_ports:
- { ports: '22022', proto: 'tcp', setype: 'ssh_port_t',
state: 'absent' }
- { ports: '22', proto: 'tcp', setype: 'ssh_port_t',
state: 'absent', local: true }
- { ports: '22023', proto: 'tcp', setype: 'ssh_port_t',
state: 'absent', local: true }
- { ports: '22023', proto: 'tcp', setype: 'ssh_port_t',
state: 'absent', local: true }

- name: include test variables
import_tasks: set_selinux_variables.yml
Expand Down

0 comments on commit 1e7aeed

Please sign in to comment.