Issue 1:
ISSUE TYPE

Bug Report

COMPONENT NAME

selinux

ANSIBLE VERSION

ansible 2.4.0.0
config file = /home/bert/.ansible.cfg
configured module search path = [u'/home/bert/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.13 (default, May 10 2017, 20:04:28) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]

CONFIGURATION

CACHE_PLUGIN(/home/bert/.ansible.cfg) = redis
COMMAND_WARNINGS(/home/bert/.ansible.cfg) = True
DEFAULT_CALLBACK_PLUGIN_PATH(/home/bert/.ansible.cfg) = [u'/home/bert/.ansible/plugins/callback_plugi
DEFAULT_GATHERING(/home/bert/.ansible.cfg) = smart
DEFAULT_LOAD_CALLBACK_PLUGINS(/home/bert/.ansible.cfg) = True
DEFAULT_MANAGED_STR(/home/bert/.ansible.cfg) = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S
DEFAULT_ROLES_PATH(/home/bert/.ansible.cfg) = [u'/home/bert/.ansible/roles']
RETRY_FILES_ENABLED(/home/bert/.ansible.cfg) = False

OS / ENVIRONMENT

Management node: Fedora 25

Target machine: CentOS 7.4

SUMMARY

After running a playbook with the SELinux module, the /etc/selinux/config file no longer has line endings. Parsing the config file on subsequent runs of the playbook will fail, as will the sestatus command.

STEPS TO REPRODUCE

---
- hosts: srv001
become: true
tasks:
- name: Ensure SELinux is enforcing
selinux:
policy: targeted
state: enforcing

EXPECTED RESULTS

SELinux config file should contain:

$ cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

ACTUAL RESULTS

$ cat /etc/selinux/config
# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=enforcing# SELINUXTYPE= can take one of three two values:# targeted - Targeted processes are protected,# minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection.SELINUXTYPE=targeted

Issue 2:
ISSUE TYPE

Bug Report

COMPONENT NAME

selinux

ANSIBLE VERSION

ansible 2.4.0.0

CONFIGURATION

ANSIBLE_SSH_PIPELINING(/Users/mwillsher/src/cloud-deployment/ansible-playbooks/ansible.cfg) = True
CACHE_PLUGIN(/Users/mwillsher/src/cloud-deployment/ansible-playbooks/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/Users/mwillsher/src/cloud-deployment/ansible-playbooks/ansible.cfg) = facts
CACHE_PLUGIN_TIMEOUT(/Users/mwillsher/src/cloud-deployment/ansible-playbooks/ansible.cfg) = 600
DEFAULT_GATHERING(/Users/mwillsher/src/cloud-deployment/ansible-playbooks/ansible.cfg) = smart
DEFAULT_HOST_LIST(/Users/mwillsher/src/cloud-deployment/ansible-playbooks/ansible.cfg) = [u'/Users/mwillsher/src/cloud-deployment/ansible-playbooks/inventory/aws']
DEFAULT_ROLES_PATH(/Users/mwillsher/src/cloud-deployment/ansible-playbooks/ansible.cfg) = [u'/Users/mwillsher/src/cloud-deployment/ansible-playbooks/roles', u'/Users/mwillsher/sr
DISPLAY_SKIPPED_HOSTS(/Users/mwillsher/src/cloud-deployment/ansible-playbooks/ansible.cfg) = False
HOST_KEY_CHECKING(/Users/mwillsher/src/cloud-deployment/ansible-playbooks/ansible.cfg) = False

OS / ENVIRONMENT

MacOS running Ansible

CentOS 6 target

SUMMARY

selinux module strips newlines from /etc/sysconfig/selinux

STEPS TO REPRODUCE

Before

[root@ip-10-100-151-172 ~]# more /etc/sysconfig/selinux
~
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

ansible -m selinux -a "state=disabled" IP -vvv -u root -i inventory/aws/ec2.py

After

# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=disabled# SELINUXTYPE= can take one of these two values:# targeted - Targeted processes are protected,# mls - Multi Level Security protection.SELINUXTYPE=targeted

EXPECTED RESULTS

Valuse changed in file and EOL chars left intact.

ACTUAL RESULTS

New lines removed, file invalid.