Skip to content

khangvum/homelab-ansible-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Homelab Configuration Automation with Ansible

A Homelab configuration automation solution powered by Ansible, containerized with Docker. This setup simplifies the Windows systems management by leveraging Ansible's idempotent and declarative configuration approach, streamlining Infrastructure as Code (IaC) principles for Windows and ESXi environments.

Features

  • Agentless architecture powered by Ansible, utilizing SSH.
  • Docker-based controller for environment consistency across platforms.
  • Modular role-based configuration and tag-based execution for targeted provisioning.
  • Centralized variable management using external YAML files.

Roles

Role Description
domain_creation Creates a new AD forest along with its domains and OUs
domain_join Joins computers to the domain
domain_user_configuration Manages domain user accounts_ and passwords
esxi_vm_deployment Deploys VMs on ESXi host
firewall_configuration Configures firewall rules
hostname_configuration Sets the hostname of Windows machines
hyper-v_configuration Installs Hyper-V and configures virtual switches
hyper-v_vm_deployment Deploys VMs on Hyper-V host
iis_deployment Installs and configures Internet Information Services (IIS)
local_user_configuration Manages local user accounts and passwords
ntp_configuration Configures NTP settings for time synchronization
region_configuration Sets regional and locale settings
system_configuration Applies system-wide settings
system_information Gather host information
windows_updates Performs Windows updates

Prerequisites

  1. OpenSSH Server installed on the targeted hosts. Alternatively, this can be installed via PowerShell:

    Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
  2. SSH Service enabled on the targeted hosts:

    Start-Service sshd
    Set-Service -Name sshd -StartupType 'Automatic'
  3. SSH allowed through the firewall:

    New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Profile Any
  4. SSH connection verified once from the controller to each host:

    ssh administrator@<IP_ADDRESS>

    Accept the host key on first connection by typing yes when prompted.

Applying Configuration

  1. Update the inventory and variable files:
  • Update inventory.yml to define the Windows hosts.
  • Update domain_var.yml to define the domain configuration.
  • Update user_var.yml to define all domain users.
  • Update vm_var.yml to define the VMs and their specifications to be created and configured.
  • Update windows_var.yml to define environment-specific variables (e.g., usernames, passwords, hostnames, etc.)
  1. Start the Ansible environment:

    docker compose up -d
  2. Access the running Ansible container:

    docker exec -it ansible_service /bin/bash
  3. Execute the playbook to apply the settings:

    ansible-playbook site.yml -i inventory.yml

Tip

Use -t option to selectively run specific plays:

ansible-playbook site.yml -i inventory.yml -t global_configuration

Releases

No releases published

Packages

No packages published