Debian Codegraph @

test/integration/targets/connection_winrm/tests.yml

raw
1 ---
2 - name: test out Windows WinRM specific tests
3 hosts: windows
4 force_handlers: yes
5 serial: 1
6 gather_facts: no
7
8 tasks:
9 - name: reboot the host
10 ansible.windows.win_reboot:
11
12 - name: setup remote tmp dir
13 import_role:
14 name: ../../setup_remote_tmp_dir
15
16 - name: copy across empty file
17 win_copy:
18 content: ''
19 dest: '{{ remote_tmp_dir }}\empty.txt'
20 register: winrm_copy_empty
21
22 - name: get result of copy across empty file
23 win_stat:
24 path: '{{ remote_tmp_dir }}\empty.txt'
25 register: winrm_copy_empty_actual
26
27 - name: assert copy across empty file
28 assert:
29 that:
30 - winrm_copy_empty is changed
31 - winrm_copy_empty_actual.stat.size == 0
32
33 # Ensures the connection plugin can handle a timeout
34 # without raising another error.
35 - name: run command with timeout
36 win_shell: Start-Sleep -Seconds 10
37 timeout: 5
38 register: timeout_cmd
39 ignore_errors: true
40
41 - assert:
42 that:
43 - timeout_cmd.msg is contains 'Timed out after'
44
45 - name: Test WinRM HTTP connection
46 win_ping:
47 vars:
48 ansible_port: 5985
49 ansible_winrm_scheme: http
50 ansible_winrm_transport: ntlm # Verifies message encryption over HTTP
51
52 - name: Test WinRM HTTPS connection
53 win_ping:
54 vars:
55 ansible_port: 5986
56 ansible_winrm_scheme: https
57 ansible_winrm_server_cert_validation: ignore
58
59 - name: get WinRM quota value
60 win_shell: (Get-Item WSMan:\localhost\Service\MaxConcurrentOperationsPerUser).Value
61 changed_when: false
62 register: winrm_quota
63
64 - block:
65 - name: set WinRM quota to lower value
66 win_shell: Set-Item WSMan:\localhost\Service\MaxConcurrentOperationsPerUser 3
67
68 - name: run ping with loop to exceed quota
69 win_ping:
70 loop: '{{ range(0, 4) | list }}'
71
72 always:
73 - name: reset WinRM quota value
74 win_shell: Set-Item WSMan:\localhost\Service\MaxConcurrentOperationsPerUser {{ winrm_quota.stdout | trim }}
75
76 - name: emit raw CLIXML on stderr with special chars
77 raw: $host.UI.WriteErrorLine("Test 🎵 _x005F_ _x005Z_.")
78 register: stderr_clixml
79
80 - name: assert emit raw CLIXML on stderr with special chars
81 assert:
82 that:
83 - stderr_clixml.stderr_lines == ['Test 🎵 _x005F_ _x005Z_.']
84
85 - name: Test stdin write failure error message
86 test_stdin_failure:
87 ignore_errors: true
88 register: stdin_write_fail
89
90 - assert:
91 that:
92 - stdin_write_fail is failed
93 - stdin_write_fail.warnings | default([]) | select('search', warning_substring) | list | length > 0
94 vars:
95 warning_substring: "ERROR DURING WINRM SEND INPUT TO "