FL1GHT5 Lab • Linux & Servers

Use Ansible to Configure Multiple Linux Servers

Who This Is For

Intermediate.

Think of it like a recipe card instead of cooking from memory every time. Write the steps once, and every kitchen that follows the card turns out the same dish.

What You'll Build

One playbook applies the same baseline configuration to two Linux servers.

Prerequisites

Why Configuration Drift Happens

Manual setup works fine for one server. By the third or fourth, small inconsistencies creep in silently, Ansible exists to stop that.

Core Concepts

Example Inventory

$all:
$ children:
$ docker_hosts:
$ hosts:
$ docker01:
$ docker02:
$ monitoring:
$ hosts:
$ monitor01:

Set Up SSH Keys

$ssh-copy-id user@docker01

Write Your First Playbook

$- hosts: docker_hosts
$ become: true
$ tasks:
$ - name: Update apt cache
$ apt: update_cache=yes
$ - name: Install Docker
$ apt: name=docker.io state=present

Idempotence

A well-written playbook can run repeatedly with no unintended effect, re-running it should only change what actually needs changing.

Secrets: Use Ansible Vault

$ansible-vault encrypt secrets.yml

Never commit plaintext passwords or keys to a repository, even a private one.

Roles for Reuse

Test on One Host First

Always run a new or changed playbook against a single test host with --limit before applying it fleet-wide.

Security & Backup Notes

Troubleshooting

Lab Finish Line

One playbook applies the same baseline configuration to two Linux servers.

What to Build Next

Planning a business implementation?

Explore our infrastructure and systems services.

View services