Skip to content

Commit

Permalink
inital role with config options for policy, state and booleans
Browse files Browse the repository at this point in the history
  • Loading branch information
FlatKey committed May 5, 2016
1 parent d9bae5d commit 9237e4e
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 2 deletions.
67 changes: 65 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,65 @@
# ansible-selinux-role
Advanced Base role to configure selinux through variables.
ansible-selinux-role
=========

Allows you to configure SELinux.

Config options:
* policy
* state
* booleans

Requirements
------------

Tested on RHEL 7 and CentOS 7 only.

Ansible 2.0 or above

Role Variables
--------------

The following variables are used to configure SELinux policy and state:

```
selinux_config: (optional, default: /etc/selinux/config)
selinux_policy: (optional, default: targeted)
selinux_state: (optional, only values: enforcing|permissive|disabled, default: enforcing)
```

---

The following variables are used to toggle SELinux booleans:

```
selinux_boolean:
name_of_selinux_boolean:
state: (optional, only values: yes|no default: yes)
persistent: (optional, only values: yes|no, default: yes)
```

Example Playbook
----------------

```
- hosts: server
become: yes
become_user: root
become_method: su
roles:
- { role: ansible-selinux-role }
vars:
selinux_policy: "targeted"
selinux_state: "enforcing"
selinux_boolean:
antivirus_can_scan_system:
state: yes
persistent: yes
httpd_can_sendmail:
state: yes
persistent: yes
```

License
-------

MIT
19 changes: 19 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
galaxy_info:
author: FlatKey
description: Advanced Base role to configure SELinux through variables. You can configure the SELinux policy, state and booleans.
license: MIT
min_ansible_version: 2.0
platforms:
- name: EL
versions:
- 7
galaxy_tags:
- selinux
- system
- security
- centos
- centos7
- rhel
- rhel7
dependencies: []
10 changes: 10 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: ensure libselinux-python is installed
yum: name=libselinux-python state=present

- name: configure selinux policy and state
selinux: conf={{selinux_config|default('/etc/selinux/config')}} policy={{selinux_policy|default('targeted')}} state={{selinux_state|default('enforcing')}}

- name: toggle selinux booleans
seboolean: name={{item.key}} state={{item.value.state|default('yes')}} persistent={{item.value.persistent|default('yes')}}
with_dict: "{{selinux_boolean|default({})}}"

0 comments on commit 9237e4e

Please sign in to comment.