Debian Codegraph @

ansible_collections/microsoft/ad/tests/integration/targets/membership/test.yml

raw symbols SCIP
1 - name: ensure time is in sync
2 hosts: windows
3 gather_facts: no
4 tasks:
5 - name: get current host datetime
6 command: date +%s
7 changed_when: False
8 delegate_to: localhost
9 run_once: True
10 register: local_time
11
12 - name: set datetime on Windows
13 ansible.windows.win_powershell:
14 parameters:
15 SecondsSinceEpoch: '{{ local_time.stdout | trim }}'
16 script: |
17 param($SecondsSinceEpoch)
18
19 $utc = [System.DateTimeKind]::Utc
20 $epoch = New-Object -TypeName System.DateTime -ArgumentList 1970, 1, 1, 0, 0, 0, 0, $utc
21 $date = $epoch.AddSeconds($SecondsSinceEpoch)
22
23 Set-Date -Date $date
24
25 - name: run microsoft.ad.membership tests
26 hosts: TEST
27 gather_facts: no
28
29 tasks:
30 - set_fact:
31 get_result_script: |
32 $Ansible.Changed = $false
33 $cs = Get-CimInstance -ClassName Win32_ComputerSystem -Property DNSHostName, Domain, PartOfDomain, Workgroup
34 $domainName = if ($cs.PartOfDomain) {
35 try {
36 [System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain().Name
37 }
38 catch [System.Security.Authentication.AuthenticationException] {
39 $cs.Domain
40 }
41 }
42 else {
43 $null
44 }
45
46 [PSCustomObject]@{
47 HostName = $cs.DNSHostName
48 NetbiosName = $env:COMPUTERNAME
49 PartOfDomain = $cs.PartOfDomain
50 DnsDomainName = $domainName
51 WorkgroupName = $cs.Workgroup
52 }
53
54 get_ad_result_script: |
55 $Ansible.Changed = $false
56 Get-ADComputer -Filter { Name -ne 'DC' } -Properties DistinguishedName, DNSHostName, Name, Enabled |
57 Select-Object -Property @(
58 'DistinguishedName'
59 @{ N = 'DNSHostName'; E = { $_.DNSHostName.Substring(0, $_.DNSHostName.IndexOf('.')) } }
60 'Name'
61 'Enabled'
62 )
63
64 - import_tasks: tasks/main.yml
65 - import_tasks: tasks/join_with_name_conflict.yml