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.
- 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.
| 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 |
-
OpenSSH Server installed on the targeted hosts. Alternatively, this can be installed via PowerShell:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
-
SSH Service enabled on the targeted hosts:
Start-Service sshd Set-Service -Name sshd -StartupType 'Automatic'
-
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
-
SSH connection verified once from the controller to each host:
ssh administrator@<IP_ADDRESS>
Accept the host key on first connection by typing
yeswhen prompted.
- Update the inventory and variable files:
- Update
inventory.ymlto define the Windows hosts. - Update
domain_var.ymlto define the domain configuration. - Update
user_var.ymlto define all domain users. - Update
vm_var.ymlto define the VMs and their specifications to be created and configured. - Update
windows_var.ymlto define environment-specific variables (e.g., usernames, passwords, hostnames, etc.)
-
Start the Ansible environment:
docker compose up -d
-
Access the running Ansible container:
docker exec -it ansible_service /bin/bash -
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