Skip to content

Commit 911cd40

Browse files
committed
Docs, configure hostnet
1 parent 8895cf8 commit 911cd40

File tree

5 files changed

+90
-4
lines changed

5 files changed

+90
-4
lines changed

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# ad-init
2+
3+
## What is it?
4+
5+
A testing tool that installs and configures a Windows VM with Active Directory, and configures a Stackable Data Platform
6+
cluster to use it.
7+
8+
The latter includes, for example:
9+
10+
- Rewriting the Kubernetes Corefile to delegate DNS for the AD domain
11+
- Creating a SecretClass for provisioning Kerberos principals
12+
- Creating a user for the SecretClass
13+
- Installing credentials for the above into the Kubernetes cluster
14+
15+
## What isn't it?
16+
17+
It does not configure a production-ready cluster. For example, many passwords will be the hard-coded dummy value "Asdf1234".
18+
19+
It also assumes that the Kubernetes cluster and Windows VM will be running on the same machine, or have full connectivity between each other.
20+
21+
## Prerequisites
22+
23+
- Libvirt and QEMU
24+
- Ansible
25+
- A Windows Server installation ISO (download from https://info.microsoft.com/ww-landing-windows-server-2022.html)
26+
- A Kubernetes cluster (kind is suggested) running the Stackable Data Platform
27+
28+
In addition, for a completely unattended installation, the ISO must be patched using cdrtools.
29+
30+
## Using it
31+
32+
1. Put your Windows ISO in `target/Windows Server 2022 EVAL.iso` (or modify `install_iso_windows` to point at it)
33+
2. Run `ansible-playbook install.yaml -i inventory.ini`
34+
3. Open virt-manager
35+
4. When the VM appears, open it and answer the "press any key to boot" prompt (reboot the VM if you missed it)
36+
5. Wait for the playbook to complete
37+
6. Done!
38+
39+
### Completely unattended (noprompt patch)
40+
41+
The "press any key to boot" prompt can be disabled by patching the Windows ISO, but this requires a slightly manual one-time process as root:
42+
43+
```shell
44+
mkdir tmp
45+
sudo mount "/path/to/Windows Server 2022 EVAL.iso" tmp -o loop -t udf
46+
mkisofs -o windows-2k22-noprompt.iso --udf -eltorito-boot efi/microsoft/boot/efisys_noprompt.bin --iso-level 4 tmp
47+
sudo umount tmp
48+
rmdir tmp
49+
```
50+
51+
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.
52+
53+
## Troubleshooting
54+
55+
### LDAP error: connection reset by peer
56+
57+
Once everything installed, it will take a little bit for Windows to decide to provision a certificate for the domain controller. It should resolve itself after a few minutes.

roles/create-vm/defaults/main.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ vm_disk_name: stackable-adds-test.qcow2
77
vm_disk_pool: default
88
vm_disk_size_gib: 30
99
vm_disk_format: qcow2
10-
vm_disk_path: /var/lib/libvirt/images/stackable-adds-test.qcow2
1110

12-
install_iso_windows: /mnt/data/DL/OS/Windows Server 2022 EVAL.iso
11+
vm_network_hostnet_name: stackable-adds-test-hostnet
12+
vm_network_hostnet_subnet: 192.168.197.0/24
13+
vm_network_internet_name: default
14+
15+
install_iso_windows: "{{ lookup('first_found', 'target') }}/Windows Server 2022 EVAL.iso"
1316

1417
install_iso_virtio_win_url: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.248-1/virtio-win-0.1.248.iso
1518
install_iso_virtio_win_checksum: sha256:d5b5739cf297f0538d263e30678d5a09bba470a7c6bcbd8dff74e44153f16549

roles/create-vm/tasks/main.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424
url: "{{ install_exe_spice_guest_tools_url }}"
2525
checksum: "{{ install_exe_spice_guest_tools_checksum }}"
2626

27+
- name: Create VM Network
28+
community.libvirt.virt_net:
29+
name: "{{ vm_network_hostnet_name }}"
30+
command: define
31+
xml: "{{ lookup('template', 'windows-vm-network.xml.j2') }}"
32+
uri: "{{ libvirt_uri }}"
33+
- name: Start VM Network
34+
community.libvirt.virt_net:
35+
name: "{{ vm_network_hostnet_name }}"
36+
state: active
37+
uri: "{{ libvirt_uri }}"
2738
- name: Create VM
2839
community.libvirt.virt:
2940
command: define
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<network connections="1">
2+
<name>{{ vm_network_hostnet_name }}</name>
3+
<forward mode="route"/>
4+
<ip
5+
address="{{ vm_network_hostnet_subnet | ansible.utils.ipaddr('next_usable') }}"
6+
netmask="{{ vm_network_hostnet_subnet | ansible.utils.ipaddr('netmask') }}">
7+
<dhcp>
8+
<range
9+
start="{{ vm_network_hostnet_subnet | ansible.utils.next_nth_usable(2) }}"
10+
end="{{ vm_network_hostnet_subnet | ansible.utils.ipaddr('last_usable') }}"/>
11+
</dhcp>
12+
</ip>
13+
</network>

roles/create-vm/templates/windows-vm.xml.j2

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@
6464
<readonly/>
6565
</disk>
6666
<controller type="scsi" index="0" model="virtio-scsi"/>
67+
<!-- Docker/Kind does not route traffic into libvirt NAT networks properly, so configure a host-only network -->
6768
<interface type="network">
68-
<source network="routed"/>
69+
<source network="{{ vm_network_hostnet_name }}"/>
6970
<model type="virtio"/>
7071
<alias name="ua-net-hostnet"/>
7172
</interface>
73+
<!-- Routed networks require extra configuration to provide internet access, so provide a NATed secondary network interface instead -->
7274
<interface type="network">
73-
<source network="default"/>
75+
<source network="{{ vm_network_internet_name }}"/>
7476
<model type="virtio"/>
7577
<alias name="ua-net-internet"/>
7678
</interface>

0 commit comments

Comments
 (0)