You could harden / obfuscate your system by making important files immutable such as the '/etc/sssd/sssd.conf' or '/etc/selinux/config' to prevent automatic changes to these files. I'll template these using ansible to have a deployment workflow so that all my systems are equal and I can make changes in a deployment fashion.
Here are some tasks to give you a basic idea:
- name: selinux conig immutable block
block:
- name: configure selinux config
template:
src: templates/etc/selinux/config.j2
dest: /etc/selinux/config
owner: root
group: root
mode: '0644'
tags:
- selinux_config
- name: set immutable attribute
file:
path: /etc/selinux/config
attr: '+i'
rescue:
- name: unset immutable attribute
file:
path: /etc/selinux/config
attr: '-i'
- name: configure selinux config
template:
src: templates/etc/selinux/config.j2
dest: /etc/selinux/config
owner: root
group: root
mode: '0644'
tags:
- selinux_config
- name: set immutable attribute
file:
path: /etc/selinux/config
attr: '+i'
Another example templating '/etc/sssd/sssd.conf':
- name: sssd config immutable block
block:
- name: configure sssd properly
template:
src: roles/base/templates/etc/sssd/sssd.conf.j2
dest: /etc/sssd/sssd.conf
owner: root
group: root
mode: '0600'
notify: restart sssd.service
- name: set immutable attribute
file:
path: /etc/sssd/sssd.conf
attr: '+i'
rescue:
- name: unset immutable attribute
file:
path: /etc/sssd/sssd.conf
attr: '-i'
- name: configure sssd properly
template:
src: roles/base/templates/etc/sssd/sssd.conf.j2
dest: /etc/sssd/sssd.conf
owner: root
group: root
mode: '0600'
notify: restart sssd.service
- name: set immutable attribute
file:
path: /etc/sssd/sssd.conf
attr: '+i'
This will try to template the file and return 'OK' if everything is as it's declared. If that's not the case, however, it will return a failed and jump to the block's rescue which- unsets the immutable bit
- templates the file and notifies the handler if defined
- sets the immutable bit
At this point, this is more of an 'extra-mile' approach and might not be useful in every deployment.
Feel free to comment and / or suggest a topic.
Comments
Post a Comment