This project containerizes the Ansible playbook for configuring Windows servers using Docker.
- Docker installed on your system
- Docker Compose installed
- Access to Windows servers with WinRM enabled
.
├── Dockerfile # Docker image definition
├── docker-compose.yml # Docker Compose configuration
├── test-ansible.yml # Ansible playbook
├── inventory.ini # Ansible inventory file
├── vaults/ # Directory for vault files
│ └── windows-password.yml
└── README.md # This file
mkdir -p vaultsCreate vaults/windows-password.yml with your credentials:
ansible_user: "YourWindowsUsername"
ansible_password: "YourWindowsPassword"Edit inventory.ini to add your Windows servers:
[windows]
windows-server ansible_host=192.168.1.100docker build -t ansible-windows .Option A: Using Docker Compose
docker-compose upOption B: Using Docker directly
docker run --rm -v "%cd%\test-ansible.yml:/ansible/playbooks/test-ansible.yml" -v "%cd%\inventory.ini:/ansible/inventory.ini" -v "%cd%\vaults:/etc/ansible/vaults" --network host ansible-windows ansible-playbook -i /ansible/inventory.ini test-ansible.ymlOption C: Interactive shell for debugging
docker run -it --rm -v "%cd%\test-ansible.yml:/ansible/playbooks/test-ansible.yml" -v "%cd%\inventory.ini:/ansible/inventory.ini" -v "%cd%\vaults:/etc/ansible/vaults" --network host ansible-windows /bin/bash- Installs pywinrm on localhost
- Configures WinRM connection parameters
- Downloads KcsSetup.exe from the specified URL
- Installs the package on Windows Server
- Update the package URL in
test-ansible.yml(line withurl: http://10.22.21.172:8081/share/KcsSetup.exe) - Modify WinRM settings if needed
- Add more Windows servers to
inventory.ini
- Ensure WinRM is enabled on target Windows servers
- Verify network connectivity to Windows servers
- Check that credentials in vault file are correct
- For WinRM port issues, ensure port 5986 is accessible