Skip to content

Commit c740732

Browse files
committed
Added windows 11 molecule test
1 parent f7b1fc8 commit c740732

File tree

12 files changed

+202
-0
lines changed

12 files changed

+202
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,4 @@ If you would like to perform testing, you need to follow the steps in the table
340340
| target | *-container@any | *-test@any |
341341
|-----|-----|-----|
342342
| Windows 2025 | [windows2025-container@any](molecule/windows2025-container@any/README.md) | [windows2025-test@any](molecule/windows2025-test@any/README.md) |
343+
| Windows 11 | [windows11-container@any](molecule/windows11-container@any/README.md) | [windows11-test@any](molecule/windows11-test@any/README.md) |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM dockurr/windows
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# windows11-container@any
2+
3+
NOTE: only support molecule `create` sequence, cant test `converge` automatically.
4+
5+
```bash
6+
molecule --debug -vvv create --scenario-name windows11-container@any
7+
```
8+
9+
then go `http://localhost:8116`, create username `docker` with password `4Test@ansible`,
10+
and enable ssh login, it will use by [windows11-test@any/converge](../windows11-test@any/converge.yml)
11+
12+
after that use [windows11-test@any](../windows11-test@any/README.md)
13+
14+
15+
finally destroy it
16+
17+
```bash
18+
molecule --debug -vvv destroy --scenario-name windows11-container@any
19+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
# This is an example playbook to execute Ansible tests.
3+
4+
- name: Converge
5+
hosts: localhost
6+
connection: local
7+
tasks:
8+
- name: Converge assert
9+
ansible.builtin.assert:
10+
that: true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
winrm quickconfig -q -transport:http
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# skip role name check
3+
# see https://github.com/ansible/ansible-compat/issues/78
4+
role_name_check: 1
5+
dependency:
6+
name: galaxy
7+
# need update `community.docker` support `cgroupns_mode` by molecule-plugins[docker]
8+
enabled: true
9+
options:
10+
role-file: requirements.yml
11+
driver:
12+
name: docker
13+
platforms:
14+
- name: windows11-container
15+
image: dockurr/windows
16+
privileged: true
17+
override_command: false
18+
env:
19+
DISK_SIZE: "24G"
20+
VERSION: "11"
21+
USERNAME: "docker"
22+
PASSWORD: "4Test@ansible"
23+
VMX: "Y"
24+
devices:
25+
- /dev/kvm
26+
- /dev/net/tun
27+
capabilities:
28+
- NET_ADMIN
29+
published_ports:
30+
- 8116:8006
31+
- 11389:3389/tcp
32+
- 11389:3389/udp
33+
- 11985:5985
34+
volumes:
35+
- ${MOLECULE_SCENARIO_DIRECTORY}/install.bat:/oem/install.bat
36+
# some file permission cant auto cleanup need manual remove
37+
- $MOLECULE_EPHEMERAL_DIRECTORY/.storage:/storage
38+
cgroupns_mode: host
39+
provisioner:
40+
name: ansible
41+
playbooks:
42+
cleanup: ../shared/cleanup.yml
43+
verifier:
44+
name: ansible
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
# This is an example playbook to execute Ansible tests.
3+
4+
- name: Verify
5+
hosts: all
6+
tasks:
7+
- name: Verify assert
8+
ansible.builtin.assert:
9+
that: true

molecule/windows11-test@any/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# windows11-test@any
2+
3+
NOTE: You need to manually restart the Windows container in order to proceed with the RUNNING HANDLER [docker : Reboot system] task, especially when encountering the TianoCore boot hang issue.
4+
5+
NOTE: only support molecule `converge` sequence, cant test `create` automatically.
6+
7+
before test, use [windows11-container@any](../windows11-container@any/README.md) first,
8+
then go `http://localhost:8116`, create username `docker` with password `4Test@ansible`,
9+
and enable ssh login, it will use by [windows11-test@any/converge](../windows11-test@any/converge.yml)
10+
11+
```bash
12+
molecule --debug -vvv test --scenario-name windows11-test@any
13+
```
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
vars:
5+
docker_config_service: true
6+
docker_daemon_file: "%userprofile%\\.docker\\daemon.json"
7+
docker_opts:
8+
builder:
9+
gc:
10+
defaultKeepStorage: 20GB
11+
enabled: true
12+
experimental: false
13+
features:
14+
buildkit: true
15+
insecure-registries:
16+
- http://nexus.lan:8082
17+
docker_version: 4.39.0
18+
# NOTE: TianoCore may hang during boot;
19+
# make sure to allow sufficient wait time.
20+
docker_windows_reboot_timeout: 86400
21+
tasks:
22+
- name: Include docker
23+
ansible.builtin.include_role:
24+
name: docker
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
# skip role name check
3+
# see https://github.com/ansible/ansible-compat/issues/78
4+
role_name_check: 1
5+
dependency:
6+
name: galaxy
7+
# need update `community.docker` support `cgroupns_mode` by molecule-plugins[docker]
8+
enabled: true
9+
options:
10+
role-file: requirements.yml
11+
driver:
12+
# Automatically use the default driver to ensure compatibility with both pre-Molecule 6 and post-Molecule 6 versions.
13+
# name: delegated
14+
options:
15+
managed: False
16+
ansible_connection_options:
17+
ansible_host: localhost
18+
ansible_connection: winrm
19+
ansible_winrm_scheme: http
20+
ansible_port: "11985"
21+
ansible_winrm_transport: ntlm
22+
ansible_user: docker
23+
ansible_password: 4Test@ansible
24+
ansible_become_password: 4Test@ansible
25+
ansible_winrm_server_cert_validation: ignore
26+
platforms:
27+
- name: windows11-test
28+
provisioner:
29+
name: ansible
30+
playbooks:
31+
prepare: ./prepare.yml
32+
converge: ./converge.yml
33+
verifier:
34+
name: ansible
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
- name: Prepare
3+
hosts: localhost
4+
connection: local
5+
tasks:
6+
- name: Debug ansible_python_interpreter
7+
ansible.builtin.debug:
8+
msg: "{{ ansible_python_interpreter }}"
9+
10+
- name: Install winrm
11+
ansible.builtin.pip:
12+
name: pywinrm==0.4.3
13+
state: present
14+
15+
- name: Include shared prepare
16+
ansible.builtin.import_playbook: ../shared/prepare.yml
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
# This is an example playbook to execute Ansible tests.
3+
4+
- name: Verify
5+
hosts: all
6+
vars:
7+
package: Docker
8+
tasks:
9+
- name: Read daemon.json
10+
ansible.builtin.slurp:
11+
src: "%userprofile%\\.docker\\daemon.json"
12+
register: daemon_json_content
13+
14+
- name: Parse JSON and check values
15+
ansible.builtin.set_fact:
16+
daemon_json: "{{ daemon_json_content['content'] | b64decode | from_json }}"
17+
18+
- name: Ensure builder.gc.enabled is defined
19+
ansible.builtin.assert:
20+
that:
21+
- daemon_json.builder.gc.enabled is defined
22+
- daemon_json.builder.gc.enabled | bool
23+
fail_msg: "'builder.gc.enabled' must be set to 'true' in '%userprofile%\\.docker\\daemon.json'"
24+
25+
- name: Ensure insecure-registries contains http://nexus.lan:8082
26+
ansible.builtin.assert:
27+
that:
28+
- "'insecure-registries' in daemon_json"
29+
- "'http://nexus.lan:8082' in daemon_json['insecure-registries']"
30+
fail_msg: "'http://nexus.lan:8082' is missing from insecure-registries in '%userprofile%\\.docker\\daemon.json'"

0 commit comments

Comments
 (0)