İçeriğe Atla
Mustafa Erbay
Tutorials · 9 min read · görüntülenme Türkçe oku
100%

Detecting Server Configuration Drift with Ansible

A guide to Ansible-based drift auditing for measuring and reporting deviations from the expected state on Linux servers.

Detecting Server Configuration Drift with Ansible — cover image

Defining server standards in code on its own is not enough; you also need to regularly verify that live systems actually match those definitions. Drift detection makes the differences caused by manual interventions, emergency fixes, or forgotten package changes visible. For this work, Ansible is highly effective not just as a deployment tool but also as an audit tool.

Diagram showing the Ansible drift detection flow

What exactly is drift?

It is when a server deviates from its expected state. This deviation can show up in:

  • The list of installed packages
  • Configuration file contents
  • Running service status
  • Open ports and listening processes
  • Authorized user or group memberships

These differences may seem minor, yet they create serious issues for security, operations, and auditability.

Approach: observe before you enforce

In the first phase, the goal is not to auto-correct drift but to make it visible. For this, --check mode, changed_when, failed_when, and custom verification tasks can be used together.

A simple example:

- name: SSH ayarini denetle
  ansible.builtin.lineinfile:
    path: /etc/ssh/sshd_config
    regexp: '^PasswordAuthentication'
    line: 'PasswordAuthentication no'
  check_mode: true
  register: ssh_policy

- name: Sapma varsa raporla
  ansible.builtin.debug:
    msg: "SSH politikasi beklenen durumdan sapmis"
  when: ssh_policy.changed

This pattern lets you see the difference without mutating the live server.

The most useful audit areas

To start, the following control sets generate high value:

  1. Package and repository standards
  2. SSH and basic hardening settings
  3. Whether security agents are actually running
  4. Time synchronization and log shipping
  5. The list of authorized users

These areas yield rapid security feedback, especially on servers with administrative access.

A sample reporting approach

Rather than leaving the Ansible output only in the terminal, turning it into a JSON or Markdown report is more practical. The simple approach:

  • Group inventory by team or environment
  • Collect register output for each check
  • Compile the results into a single report file
  • Surface critical deviations through CI or cron

This way drift detection becomes continuous control instead of a one-off experiment.

When should auto-remediation be added?

Observe first, then understand the patterns. If the same deviations keep recurring, ask two questions:

  • Is this drift truly an undesired manual intervention?
  • Or is the standard definition itself out of date?

Adding auto-remediation before that answer is clear can amplify false positives. The healthy order is: visibility, classification, approved remediation, and only then full automation.

Conclusion

Server configuration drift detection with Ansible turns infrastructure standards into living controls. Especially for Linux servers, bastion systems, and enterprise service nodes, regular drift auditing surfaces security gaps, undocumented changes, and operational risk early. Discipline in infrastructure is not just about applying changes; it is also about continuously measuring deviation.

Paylaş:

Bu yazı faydalı oldu mu?

Yükleniyor...

Bu yazı nasıldı?

ME

Mustafa Erbay

Sistem Mimarisi · Network Uzmanı · Altyapı, Güvenlik ve Yazılım

2006'dan bu yana sistem mimarisi, network, sunucu altyapıları, büyük yapıların kurulumu, yazılım ve sistem güvenliği ekseninde çalışıyorum. Bu blogda sahada karşılığı olan teknik deneyimlerimi paylaşıyorum.

Kişisel Notlar

Bu notlar sadece sizde saklanır. Tarayıcınızda yerel olarak tutulur.

Hazır 0 karakter

Comments

Server-side AI Moderation

Comments are AI-moderated server-side and stored permanently.

?
0/2000

Server-side AI moderation

✉️ Free · No spam · Unsubscribe anytime

Curated digest, hand-picked by me — not the AI

Once a week: the most important post of the week, behind-the-scenes notes, and a "what I actually used this week" section. Less noise, more signal.

  • 📌
    Best of the week Single most-worth-reading post
  • 🔧
    Toolbox notes Real tools I used this week
  • 🧠
    Behind-the-scenes Notes that don't make it to blog

We don't spam. Unsubscribe anytime. · Tracked only by Umami (self-hosted, no Google).

Your Reading Stats

0

Posts Read

0m

Reading Time

0

Day Streak

-

Favorite Category

Related Posts