It’s important for a system’s configuration to comply with industry standards, regulatory requirements, and organizational policies. However, configuration drift can happen when there are manual updates or unexpected modifications over time. The IT manager and compliance team want to enforce baseline configurations that can automatically be applied to all virtual machines when drift occurs. You’ll learn how to achieve automatic configuration remediation using Automation Config.
/POV/config-management/linux/base-config/hosts.sls
hosts.sls
and examine its SaltStack State File YAML
{% if grains.os == 'Ubuntu' %}
{% set IP_ADDRESS = salt.grains.get('ip4_interfaces:ens160:0', 'NOTFOUND') %}
{% set FQDN = grains.fqdn %}
{% set HOST = grains.host %}
file_hosts:
file.managed:
- name: /etc/hosts
- contents:
- '### Warning: The contents of this file is centrally managed by Aria Automation Config ###'
- '127.0.0.1 localhost'
- '127.0.1.1 {{ FQDN }} {{ HOST }}'
- '{{ IP_ADDRESS }} {{ FQDN }} {{ HOST }}'
- user: root
- group: root
{% endif %}
/etc/hosts
file with above contents on the target minions, but we are NOT going to run it now. We will apply this state collectively as automatic configuration remediation/POV/config-management/linux/base-config/sshd.sls
sshd.sls
and examine its SaltStack State File YAML
{% if grains.os == 'Ubuntu' %}
configure_sshd:
file.managed:
- name: /etc/ssh/sshd_config
- source: salt://POV/config-management/linux/base-config/sshd_config
- makedirs: True
reload_sshd:
service.running:
- name: sshd
- enable: True
- reload: True
- watch:
- configure_sshd
{% endif %}
/POV/config-management/linux/base-config/sshd_config
in the file server, but we are NOT going to run it now. We will apply this state collectively as automatic configuration remediation/POV/config-management/linux/base-config/vmtools.sls
vmtools.sls
and examine its SaltStack State File YAML
{% if grains.os == 'Ubuntu' %}
manage_vmtools:
service.running:
- name: open-vm-tools
- enable: True
- reload: True
{% endif %}
Open VM Tools
service on the target minions, but we are NOT going to run it now. We will apply this state collectively as automatic configuration remediation/POV/config-management/linux/base-config/main.sls
main.sls
and examine its SaltStack State File YAML
include:
- pov.config-management.linux.base-config.hosts.sls
- pov.config-management.linux.base-config.sshd.sls
- pov.config-management.linux.base-config.users.sls
- pov.config-management.linux.base-config.vmtools.sls
/POV/drift-remediation/linux/config-remediation/files/beacons.conf
beacons.conf
and examine its SaltStack State File YAML
beacons:
files_to_watch:
- files:
/etc/hosts:
mask:
- modify
- delete
- delete_self
- moved_from
/etc/ssh/sshd_config:
mask:
- modify
- delete
- delete_self
- moved_from
- beacon_module: inotify
- disable_during_state_run: True
service:
- services:
open-vm-tools:
onchangeonly: True
/POV/drift-remediation/linux/config-remediation/deploy_beacon.sls
deploy_beacon.sls
and examine its SaltStack State File YAML
install_pip3_package:
pkg.installed:
- name: python3-pip
install_inotify_prerequsite:
pip.installed:
- name: pyinotify
configure_beacon:
file.managed:
- name: /etc/salt/minion.d/beacons.conf
- source: salt://POV/drift-remediation/linux/config-remediation/files/beacons.conf
- makedirs: True
# # CentOS 8 may not restart by the usual method
# restart_salt-minion-for-CentOS-8:
# service.running:
# - name: salt-minion
# - enable: True
# - watch:
# - file: /etc/salt/minion.d/beacons.conf
restart_salt-minion:
service.running:
- name: salt-minion
- enable: True
- watch:
- configure_beacon
beacons.conf
, install dependencies and restart the salt-minion
serviceDeploy Beacon for Linux
Beacon that detects hosts file, sshd config & open-vm-tools service drift
salt
Ubuntu
state.apply
base
POV.drift-remediation.linux.config-remediation.deploy_beacon
Deploy Beacon for Linux
(the job you have created in the previous task)false
base
/POV/drift-remediation/linux/config-remediation/files/reactor.conf
reactor.conf
and examine its SaltStack State File YAML
reactor:
- 'salt/beacon/*/files_to_watch//etc/hosts':
- salt://srv/reactor/remediate_hosts.sls
- 'salt/beacon/*/files_to_watch//etc/ssh/sshd_config':
- salt://srv/reactor/remediate_sshd.sls
- 'salt/beacon/*/service/open-vm-tools':
- salt://srv/reactor/remediate_vmtools.sls
/POV/drift-remediation/linux/config-remediation/deploy_reactor.sls
deploy_reactor.sls
and examine its SaltStack State File YAML
configure_reactor.conf:
file.managed:
- name: /etc/salt/master.d/reactor.conf
- source: salt://POV/drift-remediation/linux/config-remediation/files/reactors.conf
- makedirs: True
configure_sshd_remdediation:
file.managed:
- name: /srv/reactor/remediate_sshd.sls
- source: salt://POV/drift-remediation/linux/config-remediation/files/remediate_sshd.sls
- makedirs: True
configure_host_remdediation:
file.managed:
- name: /srv/reactor/remediate_hosts.sls
- source: salt://POV/drift-remediation/linux/config-remediation/files/remediate_hosts.sls
- makedirs: True
configure_vmtools_remdediation:
file.managed:
- name: /srv/reactor/remediate_vmtools.sls
- source: salt://POV/drift-remediation/linux/config-remediation/files/remediate_vmtools.sls
- makedirs: True
restart_salt_master_service:
service.running:
- name: salt-master
- watch:
- configure_reactor.conf
reactor.conf
and remediation state files to the Salt Master
Deploy Reactor for Salt Master
Reactor that remediate hosts file, sshd config & open-vm-tools service drift
salt
Linux
state.apply
base
POV.drift-remediation.linux.config-remediation.deploy_reactor
Deploy Reactor for Salt Master
(the job you have created in the previous task)false
base
Automation Config can automatically apply baseline configuration upon configuration drift: