(especially for Windows)
basic
directores
- basic usage of Ansible and Terraform
advanced
directory
- auto-configure Windows to be accessible using WinRM and SSH connections
- uses of terraform
local_file
to generate a dynamic ansible inventory file
- make sure to have an azure service principal available, which owns
Contributor Role
in an Azure subscription. - make sure to rename all
terraform.tfvars.sample
files toterraform.tfvars
and adjust your credential information. - in terraform/basic/vsphere
and
terraform/advance/vsphereadjust the
variables.tfand
main.tf` accordingly to fit into your vSphere environment.
vSphere
- Provision VM using terraform
cd terraform/basic/vsphere
terraform init
terraform plan
terraform appy
-
Make sure to enable SSH on the Windows VM
Example: https://raw.githubusercontent.com/andif888/powershell-win-openssh-server/master/enable-win-openssh-server.ps1
(!!! make sure to replace the contained SSH public key with your own public key) -
Enter IP address of the VM into ansible/basic/environment/vsphere/inventory/static_inventory
-
configure VM using ansible
cd ansible
ansible-playbook -i basic/environment/vsphere/inventory playbook_windows_feature.yml
Azure
- Provision VM using terraform
cd terraform/basic/azure
terraform init
terraform plan
terraform appy
-
Make sure to enable SSH on the Windows VM
Example: https://raw.githubusercontent.com/andif888/powershell-win-openssh-server/master/enable-win-openssh-server.ps1
(!!! make sure to replace the contained SSH public key with your own public key) -
Enter IP address of the VM into ansible/basic/environment/azure/inventory/static_inventory
-
configure VM using ansible
cd ansible
ansible-playbook -i basic/environment/azure/inventory playbook_windows_feature.yml
make sure to replace the scripts, which automate SSH Server configuration with your own ones. Otherwise I will have access to your VMs, because those scripts contain my SSH public key:
- terraform/advanced/azure/files/ConfigureRemotingForAnsible.bat
- terraform/advance/vsphere/main.tf Line 71
run_once_command_list = ["cmd.exe /C powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"[Net.ServicePointManager]::SecurityProtocol = 'Tls12'; iex ((New-Object System.Net.Webclient).DownloadString('https://raw.githubusercontent.com/andif888/run_once_cmd/master/1.ps1'))\""]
vSphere
- Provision VM using terraform
cd terraform/advanced/vsphere
terraform init
terraform plan
terraform appy
- configure VM using ansible
cd ansible
ansible-playbook -i advanced/environment/vsphere/inventory playbook_windows_feature.yml
Azure
- Provision VM using terraform
cd terraform/advanced/azure
terraform init
terraform plan
terraform appy
- configure VM using ansible
cd ansible
ansible-playbook -i advanced/environment/azure/inventory playbook_windows_feature.yml