0

Ansible for SQL Server DBAs. Available Now!

Header Logo
Blog DBA Challenges
Courses
Automated Sandbox Framework Ansible for SQL Server DBAs: Level 1
Log In
← Back to all posts
Connect
Share to…
Share

#013 Creating and Implementing Your First Policy

by Luke Campbell
Nov 16, 2024

Usually, right after building a SQL Server instance, it's in pretty good shape.  You've configured settings like maxdop, cost threshold for parallelism, max memory, etc. You've likely set up your standard maintenance jobs and set up users and roles appropriately.  

But let's say it's a year or two later, and you've been disengaged from that instance.  Are the settings you applied still intact?  Is the instance still in a good state?  There's a good chance that databases have been moved from older instances to this one.  How can you be sure they're using CHECKSUM for the page_verify option?

Multiply this scenario across 10s or 100s of instances, and it becomes overwhelming.  You're often left scrambling when the auditors show up.

Today's challenge has two objectives.

  1. Verify that Policy-Based Management is enabled.
  2. Create two policies: SQL Server Max Degree of Parallelism and Database Page Verification.

 

Ready?


Estimated time to complete: Less than 1 hour.


Step 1:  Verify that Policy-Based Management is enabled

Objective: Verify that PBM is enabled and review properties.

  1. Open SSMS and connect to your SQL Server instance.
  2. Expand Management, right-click on Policy Management, then click Properties.

Enabled - Specifies whether PBM is disabled or enabled.

HistoryRetentionDays - The number of days that policy evaluation history should be retained.  If 0, the history will not be automatically removed.  History is stored in the msdb database.

LogOnSuccess - Specifies whether PBM logs successful policy evaluations.  When true, both successful and failed policy evaluations are logged.

Step 2: Create two policies

Last week, we covered the 4 key components of PBM: Facets, Conditions, Policies, and Targets

We'll use those components to create our first policy.  Let's make the first one together.  The second will be left up to you to create on your own.

  1. Right-click Policies and select New Policy.
  2. Enter "SQL Server Max Degree of Parallelism" as the name.
  3. Click on the Check Condition drop-down menu and select "New Condition."
  4. Give the condition a name.  I named it "Maximum Degree of Parallelism."
  5. Select "Server Performance" from the Facet menu.
  6. Configure the expression as shown below and then click OK.

 

You can give the policy a description and assign it to a category.  Leave the evaluation mode set to On Demand for now.

Evaluating the Policy

Next, right-click on the new policy and then click evaluate.  If maxdop is set above 4, then the evaluation fails.  To see the details, click View in the Target details box.

I have maxdop set to 8, so the evaluation fails.

Action Item:

Continue with creating the second policy - Database Page Verification.  You'll need to identify which facet to use for your condition.  Facets can be found, along with their description, within the Facet folder under Policy Management.

Helping Others and Sharing Your Results

If you're managing many SQL Server instances, creating policies one by one isn't scalable. 

Next week, I'll introduce you to a framework that does scale.

If you have tips or experiences to share, please post them in the comments or tag me on LinkedIn with the #dbachallenges hashtag.  

Next week, we'll create a policy using PBM.

Feedback

If there's a DBA Challenge you'd like to see, let me know by replying to this email.

Feel free to reply to this email with any thoughts or questions.

Good luck, and I look forward to seeing your results!

Luke

Responses

Join the conversation
t("newsletters.loading")
Loading...
#016 Leveraging Ansible Variables to Configure Lock Pages in Memory
You've probably seen it happen.  During peak load on a SQL Server instance, the operating system occasionally pages out parts of SQL Server's memory to disk, causing performance slowdowns.  And you've probably read how Lock Pages in Memory can help address this issue.   Granting this user right can be time-consuming and error-prone when done manually especially if you need to grant the permissi...
#015 Introduction to the Automated Sandbox Framework
2025 is just around the corner, and it's shaping up to be an exciting year for DBAs.  With Windows Server 2025 already here and SQL Server 2025 on the horizon, there's no better time to sharpen your skills and prepare for what's ahead. This year, I've focused on solving a common challenge for DBAs: how to quickly and consistently build test environments for learning and experimentation. In mid-...
#014 Introduction to the Enterprise Policy-Based Management Framework
It's been a few weeks since the last edition.  Life happens--between releasing Ansible for SQL Server DBAs, celebrating Thanksgiving, preparing for Christmas, and juggling the day-to-day demands of being a full-time consultant, it's easy to feel stretched thin.  Have you ever felt that way? But here's a question:  Are we just staying busy or moving toward our goals (we like to think so)?  Are o...

DBA Challenges

Helping you become a more efficient SQL Server Database Administrator through real-world challenges and automation.
Footer Logo
Policies Contact
© 2025 AUTOMATESQL LLC

Five Steps to Spot Automation Opportunities

Wondering if that task you're working on should be automated?  With your free Time Tracker Excel workbook, you're able to easily track and analyze how you spend your time throughout the day.

 

When you signup, we'll send you periodic emails with additional free content. Unsubscribe anytime.