ansible.builtin.selinux (v2.5.10) — module

Change policy and state of SELinux

| "added in version" 0.7 of ansible.builtin"

Authors: Derek Carter (@goozbach) <goozbach@friocorte.com>

stableinterface | supported by core

Install Ansible via pip

Install with pip install ansible==2.5.10

Description

Configures the SELinux mode and policy. A reboot may be required after usage. Ansible will not issue this reboot but will let you know when it is required.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Enable SELinux
- selinux:
    policy: targeted
    state: enforcing
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Put SELinux in permissive mode, logging actions that would be blocked.
- selinux:
    policy: targeted
    state: permissive
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Disable SELinux
- selinux:
    state: disabled

Inputs

    
conf:
    aliases:
    - configfile
    - file
    default: /etc/selinux/config
    description:
    - path to the SELinux configuration file, if non-standard
    required: false

state:
    choices:
    - enforcing
    - permissive
    - disabled
    default: null
    description:
    - The SELinux mode
    required: true

policy:
    default: null
    description:
    - 'name of the SELinux policy to use (example: C(targeted)) will be required if state
      is not C(disabled)'
    required: false

Outputs

configfile:
  description: Path to SELinux configuration file
  returned: always
  sample: /etc/selinux/config
  type: string
msg:
  description: Messages that describe changes that were made
  returned: always
  sample: Config SELinux state changed from 'disabled' to 'permissive'
  type: string
policy:
  description: Name of the SELinux policy
  returned: always
  sample: targeted
  type: string
reboot_required:
  description: Whether or not an reboot is required for the changes to take effect
  returned: always
  sample: true
  type: bool
state:
  description: SELinux mode
  returned: always
  sample: enforcing
  type: string