Lesson 6 of 7 · Git for DBAs

Git in Practice

A DBA team and a server team use one repository, CODEOWNERS, pull requests, and a pipeline to automate building database servers end to end.

Beginner 7 sections 5 min read

The project

This lesson follows two teams, the server team and the DBA team, as they use Git to build one piece of end-to-end automation: a pipeline that creates a Linux database server and installs and configures Oracle Database on it, with no manual steps. It shows how Git lets two teams own their parts while delivering one working result.

Today, a new database server takes two weeks and two tickets. The server team builds a Linux virtual machine by hand, then hands it to the DBA team, who install Oracle by hand. Each team's steps are in its own documents, and the two halves often don't fit: wrong disk layout, missing packages, kernel settings forgotten.

The goal: an engineer runs one pipeline and gets a ready database server, built the same way every time. The work divides naturally:

Server team ownsDBA team owns
Terraform to create the virtual machine, disks, and networkAn Ansible role to install the Oracle software
An Ansible role for the operating system baseline: patches, hardening, users, and kernel settingsAn Ansible role to create and configure the database: parameters, users, backups, and monitoring
Together: the pipeline that runs it all, and the runbook

One shared repository

The teams agree to keep everything in one repository, db-platform, so the whole build is versioned and tested together. Each team owns its own folders:

db-platform/
├── terraform/
│   ├── modules/db-server/        # server team: VM, disks, network
│   └── envs/dev/ and envs/prod/  # settings for each environment
├── ansible/
│   ├── roles/os_baseline/        # server team: patches, hardening, kernel settings
│   ├── roles/oracle_install/     # DBA team: Oracle software
│   ├── roles/oracle_db/          # DBA team: database, users, backups, monitoring
│   └── provision.yml             # runs the roles in order
├── pipelines/provision.yml       # both teams
├── docs/runbook.md
└── CODEOWNERS

A CODEOWNERS file, supported by GitHub and GitLab, says which team must review changes to which folders. A pull request that touches the DBA team's roles can't be merged until a DBA approves it:

# CODEOWNERS
/terraform/                    @acme/server-team
/ansible/roles/os_baseline/    @acme/server-team
/ansible/roles/oracle_install/ @acme/dba-team
/ansible/roles/oracle_db/      @acme/dba-team
/pipelines/                    @acme/server-team @acme/dba-team

Agreeing the hand-off

The point where one team's work meets the other's is where things used to go wrong. So the first pull request, reviewed by both teams, writes the hand-off down as code: the variables the server team's work provides, and the DBA team's roles rely on.

# ansible/group_vars/db_servers.yml: the agreed hand-off between the teams
oracle_base: /u01/app/oracle         # server team creates and mounts /u01
oracle_data_mount: /u02              # fast disk for data files
oracle_fra_mount: /u03               # disk for the fast recovery area
oracle_os_user: oracle
oracle_os_groups: [oinstall, dba]
hugepages_enabled: true              # server team sets the kernel parameter

From then on, if either team wants to change the hand-off, it's a pull request that both teams review, rather than a surprise.

Working in parallel

SERVER TEAM MAIN DBA TEAM TerraformOS baseline install roledatabase rolebackups hand-offvariablesPR mergedPR mergedpipelineadded v1.0.0 databaseserver ready

Both teams work at the same time, each on its own branches, named after their Jira items:

  1. Server team: branch SRV-88-db-server-terraform adds the Terraform module, and a second branch adds the OS baseline role. Each pull request is reviewed within the server team, and checked by the pipeline: terraform validate and ansible-lint.
  2. DBA team: branch DBA-301-oracle-install adds the install role, then DBA-302-oracle-db the database role and backups. Kofi opens each pull request; Ama reviews it, catching that the role sets the redo log size too small for production.
  3. Where they meet: when the DBA role needs one more kernel setting, Kofi doesn't change the server team's role directly, but opens an issue, and the server team adds it in their own pull request, so each team stays the owner of its part.
  4. Together: a shared branch adds the pipeline, reviewed by both teams through CODEOWNERS.

From merge to running server

Every pull request runs quick checks. Every merge to main runs the full build in a test environment:

# pipelines/provision.yml (simplified)
on:
  pull_request:                 # on every PR: check the code
  push: { branches: [main] }    # on every merge: build a test server
jobs:
  check:
    steps:
      - run: terraform -chdir=terraform/envs/dev validate
      - run: ansible-lint ansible/
  build-test-server:
    if: github.ref == 'refs/heads/main'
    steps:
      - run: terraform -chdir=terraform/envs/dev apply -auto-approve
      - run: ansible-playbook -i inventory/dev ansible/provision.yml
      - run: ./tests/smoke_test.sh   # connect, check parameters, backups, monitoring

When the test build passes and both teams are happy, they mark the release with a tag, v1.0.0. Production servers are built only from tagged releases, after an approval in the pipeline. If a new release causes a problem, the team rebuilds from the previous tag.

What Git gave the teams

BeforeWith Git
Two separate sets of documents and manual stepsOne repository with the whole build as code
Hand-offs by ticket, often mismatchedA hand-off agreed in code and changed only through reviewed pull requests
Changes noticed only when something brokeEvery change reviewed by its owners, and tested on a real server
"Who changed the disk layout?"git log and git blame show who, when, and why
Two weeks per serverUnder an hour, the same way every time

The automation itself uses Terraform and Ansible, which have their own modules later in this path. Git is what lets the two teams build it together.

Key takeaways

  • One shared repository holds the whole build, with each team owning its own folders.
  • CODEOWNERS makes sure the right team reviews every change to its part.
  • The hand-off between teams is written as code, and changed only through pull requests both teams review.
  • Teams work in parallel on branches named after their work items, and ask each other for changes rather than editing each other's code.
  • Pull requests run quick checks, merges to main build a test server, and tagged releases go to production.