Skip to content

Commit bcb799c

Browse files
committed
Support preexisting (Cloud?) VMs
1 parent 80c842b commit bcb799c

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,30 @@ rmdir tmp
5050

5151
After this, `install_iso_windows` can be pointed at `windows-2k22-noprompt.iso` instead to fully automate the process. `ansible-playbook install.yaml -i inventory.ini` should then be enough.
5252

53+
### Running against a preinstalled Windows (such as cloud images)
54+
55+
Generally, a preinstalled Windows can be connected to by setting `ansible_connection=ssh` in `inventory.ini`, for example:
56+
57+
```
58+
sble-addc ansible_connection=ssh ansible_host=1.2.3.4 vm_network_ipv4=1.2.3.4
59+
```
60+
61+
Where `ansible_host` is the IP address that will be connected to, and `vm_network_ipv4` is the address that can be used to connect to the Windows host from the Kubernetes cluster.
62+
63+
*However*, requires SSH to be enabled manually, and for Ansible to have valid SSH authentication credentials to connect.
64+
65+
SSH can be enabled by running the following PowerShell on the Windows target:
66+
67+
``` powershell
68+
Add-WindowsCapability -Online -Name OpenSSH.Server
69+
Start-Service sshd
70+
Set-Service -Name sshd -StartupType 'Automatic'
71+
```
72+
73+
Credentials can be provided to Ansible by adding the `-u USERNAME --ask-pass` flags. Alternatively, you can install your public SSH key to the server instead of using password authentication.
74+
75+
Finally, Kubernetes must still be able to connect to the Windows's LDAP, DNS, and Kerberos services. When running in a cloud environment, this typically means running Kubernetes in the same VPC as the Windows VM.
76+
5377
## Troubleshooting
5478

5579
### LDAP error: connection reset by peer

install.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
hosts: localhost
88
roles:
99
- role: create-vm
10+
# If using a non-libvirt connection, assume that Windows is already installed
11+
when: hostvars['sble-addc'].ansible_connection == 'community.libvirt.libvirt_qemu'
1012
- name: Wait for VM to install and boot
1113
hosts: sble-addc
1214
gather_facts: false
@@ -17,6 +19,8 @@
1719
This will take a while.. if it times out, restart the playbook but leave the VM running to resume.
1820
It is normal to see a bunch of QEMU guest agent errors in the Ansible output while waiting.
1921
ansible.builtin.wait_for_connection:
22+
# When using a preinstalled Windows, assume that any such initialization is already done.
23+
when: hostvars['sble-addc'].ansible_connection == 'community.libvirt.libvirt_qemu'
2024
- name: Install AD and initialize domain controller
2125
hosts: sble-addc
2226
roles:

roles/ad-dc/tasks/main.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- name: Extract Primary IP address
1313
set_fact:
1414
vm_network_ipv4: "{{ (ansible_facts.interfaces | rekey_on_member('macaddress'))[vm_network_mac | upper].ipv4.address }}"
15+
when: not vm_network_ipv4 | default
1516

1617
- name: Name Secret-Operator User
1718
set_fact:

0 commit comments

Comments
 (0)