Monitoring and Reacting to Configuration Changes Using Policies
How to create policies to detect inventory configuration changes and send email notifications
Red Hat Customer Content Services
Abstract
Chapter 1. Receiving automatic notifications from Policies about changes in your Insights for Red Hat Enterprise Linux inventory
Policies service users can set notification preferences that notify the user of changes to systems or potential security issues.
1.1. Policies detection and notification of inventory configuration changes
Policies you create are applicable to all systems in your Insights for Red Hat Enterprise Linux inventory. You can create and manage policies using the Insights for Red Hat Enterprise Linux user interface or via API.
Policies can assist you by managing tasks such as:
- Raising an alert when particular conditions occur in your system configuration.
- Emailing a team when security packages are out of date on a system.
Using policies to monitor configuration changes in your inventory and notifying by email requires:
- Setting user email preferences (if not already set).
- Creating a policy to detect configuration changes as a trigger and selecting email as the trigger action.
- Configure User Access in Red Hat Insights for Red Hat Enterprise Linux > Settings > User Access.
- See User Access Configuration Guide for Role-based Access Control (RBAC) for more information about this feature and example use cases.
1.2. Enabling notifications and integrations for the policies service
You can enable the notifications service on Red Hat Hybrid Cloud Console to send notifications whenever the policy service detects an issue and generates an alert. Using the notifications service frees you from having to continually check the Red Hat Insights Dashboard for alerts.
For example, you can configure the notifications service to automatically send an email message whenever the policies service detects that a server’s security software is out of date, or to send an email digest of all the alerts that the policies service generates each day.
In addition to sending email messages, you can configure the notifications service to send polcies event data in other ways:
- Using an authenticated client to query Red Hat Insights APIs for event data
- Using webhooks to send events to third-party applications that accept inbound requests
- Integrating notifications with applications such as Splunk to route policies events to the application dashboard
Enabling the notifications service requires three main steps:
- First, an Organization Administrator creates a User access group with the Notifications administrator role, and then adds account members to the group.
- Next, a Notifications administrator sets up behavior groups for events in the notifications service. Behavior groups specify the delivery method for each notification. For example, a behavior group can specify whether email notifications are sent to all users, or just to Organization administrators.
- Finally, users who receive email notifications from events must set their user preferences so that they receive individual emails for each event.
Additional resources
For more information about how to set up notifications for policies alerts, see Red Hat Insights Notifications.
Chapter 2. User preferences
Update your information and set email preferences for Red Hat Hybrid Cloud Console services in your user preferences.
2.1. Setting user preferences
You can set or update your email preferences as follows.
Procedure
- Click the user menu located on the upper-right side, then go to: User preferences > Notifications > Red Hat Enterprise Linux https://console.redhat.com/user-preferences/email. Check the appropriate boxes to define your policies notification preferences.
Depending on your email notification preferences, you can subscribe to Instant notification emails for each system with triggered policies or a Daily digest summarizing triggered application events in a 24-hour time frame.
NoteSubscribing to instant notification can result in receiving many emails on large inventories, that is, one email per system checking in.
- Click Submit.
Chapter 3. Creating policies
The following workflow examples explain how to create several types of policies that detect system configuration changes and send notification of the changes by email.
When creating a policy, if you see a warning message that you have not opted in for email alerts, set your preferences to receive email from your policies. See Chapter 2, User preferences, for information.
3.1. Creating a policy to ensure public cloud providers are not over provisioned
Procedure
- In Red Hat Hybrid Cloud Console, go to Red Hat Enterprise Linux > Policies.
- Click Create policy.
- On the Create a policy page, click From scratch or As a copy of existing Policy as required. Note that the As a copy of existing Policy option will prompt you to select a policy from the list of existing policies to use as a starting point.
- Click Next.
Enter Condition. In this case, enter: facts.cloud_provider in ['alibaba', 'aws', 'azure', 'google'] and (facts.number_of_cpus >= 8 or facts.number_of_sockets >=2). This condition will detect if an instance running on the specified public cloud providers are running with CPU hardware higher than the allowed limit.
NoteYou can expand What condition can I define? and/or Review available system facts to view an explanation of conditions you can use, and see the available system facts, respectively. In this section are examples of syntax you can use.
- Click Validate condition.
- Once the condition is validated, click Next.
- On the Trigger actions page, click Add trigger actions. If notifications is greyed out, select Notification settings in the notifications box. Here you can customize notificaitons and their behaviors.
Click Next.
NoteOn the Trigger actions page, you can also enable email alerts as well as open email preferences.
- On the Review and enable page, click the toggle switch to activate the policy and review its details.
- Click Finish.
Your new policy is created. When the policy is evaluated on a system check-in, if the condition in the policy is met, Policies automatically sends an email to all users on the account with access to Policies, depending on their email preferences.
3.2. Creating a policy to detect if systems are running an outdated version of RHEL
You can create a policy that detects if systems are running outdated versions of RHEL and notifies you by email about what it finds.
Procedure
- In Red Hat Hybrid Cloud Console, go to Red Hat Enterprise Linux > Policies.
- Click Create policy.
- On the Create policy page, click From scratch or As a copy of existing Policy as required. Note that the As a copy of existing Policy option prompts you to select a policy from the list of existing policies to use as a starting point.
- Click Next.
- Enter a Name and Description for the policy.
- Click Next.
- Enter Condition. In this case, enter facts.os_release < 8.1. This condition will detect if systems still run an outdated version of our operating system based on RHEL 8.1.
- Click Validate condition, then click Next.
- On the Trigger actions page, click Add trigger actions and select Email.
- Click Next.
- On the Review and activate page, click the toggle switch to activate the policy and review its details.
- Click Finish.
Your new policy is created. When the policy is evaluated on a system check-in, if the condition in the policy is triggered, the policies service automatically sends an email to all users on the account with access to Policies, depending on their email preferences.
3.3. Creating a policy to detect a vulnerable package version based on recent CVE
You can create a policy that detects vulnerable package versions based on recent CVE and notifies you by email about what it finds.
Procedure
- In Red Hat Hybrid Cloud Console, go to Red Hat Enterprise Linux > Policies.
- Click Create policy.
- On the Create Policy page, click From scratch or As a copy of existing Policy as required. Note that the As a copy of existing Policy option will prompt you to select a policy from the list of existing policies to use as a starting point.
- Click Next.
- Enter a Name and Description for the policy.
- Click Next.
-
Enter Condition. In this case, enter facts.installed_packages contains ['openssh-4.5']. This condition will detect if systems still run a vulnerable version of an
openssh
package based on recent CVE. - Click Validate condition, then click Next.
- On the Trigger actions page, click Add trigger actions and select Email.
- Click Next.
- On the Review and activate page, click the toggle switch to activate the policy and review its details.
- Click Finish.
Your new policy is created. When the policy is evaluated on a system check-in, if the condition in the policy is met, Policies automatically sends an email to all users on the account with access to Policies, depending on their email preferences.
Chapter 4. Reviewing and managing policies
You can review and manage all created policies (enabled and disabled) by navigating to Red Hat Enterprise Linux > Policies.
You can filter the list of policies by name and by active state. You can click the options menu next to a policy to perform the following operations:
- Enable and disable
- Edit
- Duplicate
- Delete
Additionally, you can perform the following operations in bulk by selecting multiple policies from the list of policies and clicking the options menu
located next to the Create policy button at the top:
- Delete policies
- Enable policies
- Disable policies
If you see a warning message about email alerts not opted in, set your preferences to receive email from your policies as described in Chapter 2, User preferences.
Chapter 5. Appendix
This appendix contains the following reference materials:
- System Facts
- Operators
5.1. System Facts
The table below displays the system facts for use in system comparisons.
Table 5.1. System Facts and Their Functions
Fact Name | Description | Example Value |
---|---|---|
| Category with a list of Ansible-related facts | controller_version with a value of 4.0.0 |
| System architecture |
|
|
BIOS release date; typically | 01/01/2011 |
| BIOS vendor name | LENOVO |
| BIOS version | 1.17.0 |
|
Cloud vendor. Values are |
|
| Number of CPU cores per socket | 2 |
|
Category with a list of CPU flags. Each name is the CPU flag (ex: |
|
|
Category with a list of enabled services. Each name in the category is the service name (ex: |
|
| System Fully Qualified Domain Name | system1.example.com |
|
System infrastructure; common values are |
|
|
Infrastructure vendor; common values are |
|
| List of installed RPM packages. This is a category. |
|
|
Category with a list of installed services. Each name in the category is the service name (ex: |
|
|
List of kernel modules. Each name in the category is the kernel module (ex: |
|
|
The boot time in |
|
| Category with a list of MSSQL-related facts | mssql_version with a value of 15.0.4153.1 |
| List of facts related to network interfaces. | |
There are six facts for each interface: | ||
Each interface (ex: | ||
Most network interface facts are compared to ensure they are equal across systems. However, | ||
| Total number of CPUs |
|
| Total number of sockets |
|
| Kernel version |
|
| Kernel release |
|
| List of running processes. The fact name is the name of the process, and the value is the instance count. |
|
| SAP instance number |
|
| SAP system ID (SID) |
|
| Boolean field that indicates if SAP is installed on the system |
|
| SAP version number |
|
| Boolean field that indicates is a system is registered to a Satellite server. |
|
| Current SELinux mode |
|
| SELinux mode set in the config file |
|
| Total system memory in human-readable form |
|
|
Current profile resulting from the command |
|
|
List of yum repositories. The repository name is added to the beginning of the fact. Each repository has the associated facts |
|
5.2. Operators
Table 5.2. Available Operators in Conditions
Operators | Value |
---|---|
Logical Operators | AND |
OR | |
Boolean Operators | EQUAL |
NOTEQUAL | |
Numeric Compare Operators | GT |
GTE | |
LT | |
LTE | |
String Compare Operator | CONTAINS |
Array Operators | IN |
CONTAINS | |
Parser Operators | OR |
AND | |
NOT | |
EQUAL | |
NOTEQUAL | |
CONTAINS | |
NEG |
Providing feedback on Red Hat documentation
We appreciate your feedback on our documentation. To provide feedback, highlight text in a document and add comments.
Prerequisites
- You are logged in to the Red Hat Customer Portal.
- In the Red Hat Customer Portal, the document is in the Multi-page HTML viewing format.
Procedure
To provide your feedback, perform the following steps:
Click the Feedback button in the top-right corner of the document to see existing feedback.
NoteThe feedback feature is enabled only in the Multi-page HTML format.
- Highlight the section of the document where you want to provide feedback.
Click the Add Feedback pop-up that appears near the highlighted text.
A text box appears in the feedback section on the right side of the page.
Enter your feedback in the text box and click Submit.
A documentation issue is created.
- To view the issue, click the issue link in the feedback view.