Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selinux modules don't change SELINUXTYPE when it's not exist in /etc/selinux/config. #23

Closed
nfwork01 opened this issue May 5, 2020 · 1 comment · Fixed by #52
Closed

Comments

@nfwork01
Copy link

nfwork01 commented May 5, 2020

SUMMARY

SELinux moduled does not add new SELINUXTYPE line in /etc/selinux/config when that line does not exits.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

selinux

ANSIBLE VERSION
ansible 2.9.7                                                                                                                                                                                               python version = 3.8.2 (default, Mar 13 2020, 10:14:16) [GCC 9.3.0]
CONFIGURATION

Ansible tasks

- name: "1.6.1.2 - Ensure the SELinux state is enforcing"
  selinux:
    policy: targeted
    state: enforcing
  register: tmp

# For detailed information, no need for production.
- debug:
    msg: "{{ tmp }}"

/etc/selinux/config

# No SELINUXTYPE setting on the conf file
# selinux module works well when the line exists.
SELINUX=disabled
EXPECTED RESULTS

/etc/selinux/config

SELINUX=enforcing
SELINUXTYPE=targeted
ACTUAL RESULTS

/etc/selinux/config

SELINUX=enforcing

tasks log

TASK [cis_rhel7 : 1.6.1.2 - Ensure the SELinux state is enforcing] [WARNING]: Reboot is required to set SELinux state to 'enforcing'
changed: [10.0.0.129]

TASK [cis_rhel7 : debug] *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
ok: [10.0.0.129] => {
    "msg": {
        "changed": true,
        "configfile": "/etc/selinux/config",
        "failed": false,
        "msg": "SELinux policy configuration in '/etc/selinux/config' changed from 'None' to 'targeted'",
        "policy": "targeted",
        "reboot_required": true,
        "state": "enforcing",
        "warnings": [
            "Reboot is required to set SELinux state to 'enforcing'"
        ]
    }
}

task log says "policy was changed to targeted" but not reflected to the config file.

maxamillion added a commit to maxamillion/ansible.posix that referenced this issue Jun 18, 2020
Previously the selinux module would only edit the state of found
configuration keys SELINUX and SELINUXTYPE in /etc/selinux/config but
would not add them with desired state if they were not found.

Fixes ansible-collections#23

ansible-collections#23

Signed-off-by: Adam Miller <admiller@redhat.com>
maxamillion added a commit to maxamillion/ansible.posix that referenced this issue Jun 18, 2020
Previously the selinux module would only edit the state of found
configuration keys SELINUX and SELINUXTYPE in /etc/selinux/config but
would not add them with desired state if they were not found.

Fixes ansible-collections#23

ansible-collections#23

Signed-off-by: Adam Miller <admiller@redhat.com>
@maxamillion
Copy link
Collaborator

Fixed here: #52

maxamillion added a commit to maxamillion/ansible.posix that referenced this issue Jun 18, 2020
Previously the selinux module would only edit the state of found
configuration keys SELINUX and SELINUXTYPE in /etc/selinux/config but
would not add them with desired state if they were not found.

Fixes ansible-collections#23

ansible-collections#23

Signed-off-by: Adam Miller <admiller@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants