mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
fix Windows tests with hardcoded Administrator account (#35339)
* Admin account is not always called Administrator (eg Azure) * this fixes some, but not all issues related to the Administrator account on non-English Windows as well (still numerous references to "Administrators" and other en-US Windows group names)
This commit is contained in:
parent
3e7671879f
commit
2a9ec6bdbf
5 changed files with 103 additions and 58 deletions
|
@ -1,4 +1,12 @@
|
|||
---
|
||||
- name: Look up built-in Administrator account name (-500 user whose domain == computer name)
|
||||
raw: $machine_sid = (Get-CimInstance Win32_UserAccount -Filter "Domain='$env:COMPUTERNAME'")[0].SID -replace '(S-1-5-21-\d+-\d+-\d+)-\d+', '$1'; (Get-CimInstance Win32_UserAccount -Filter "SID='$machine_sid-500'").Name
|
||||
check_mode: no
|
||||
register: admin_account_result
|
||||
|
||||
- set_fact:
|
||||
admin_account_name: "{{ admin_account_result.stdout_lines[0] }}"
|
||||
|
||||
- name: ensure task is deleted before test
|
||||
win_scheduled_task:
|
||||
name: '{{test_scheduled_task_stat_name}}'
|
||||
|
@ -34,7 +42,7 @@
|
|||
name: '{{test_scheduled_task_stat_name}}'
|
||||
state: present
|
||||
logon_type: interactive_token
|
||||
username: Administrator
|
||||
username: '{{ admin_account_name }}'
|
||||
author: Ansible Author
|
||||
description: Fake description
|
||||
execution_time_limit: PT23H
|
||||
|
@ -102,7 +110,7 @@
|
|||
- stat_task_present.principal.group_id == None
|
||||
- stat_task_present.principal.logon_type == "TASK_LOGON_INTERACTIVE_TOKEN"
|
||||
- stat_task_present.principal.run_level == "TASK_RUNLEVEL_LUA"
|
||||
- stat_task_present.principal.user_id.endswith("Administrator")
|
||||
- stat_task_present.principal.user_id.endswith(admin_account_name)
|
||||
- stat_task_present.registration_info.author == "Ansible Author"
|
||||
- stat_task_present.registration_info.date is defined
|
||||
- stat_task_present.registration_info.description == "Fake description"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue