Debian Codegraph @

test/integration/targets/win_app_control/setup.yml

raw
1 - name: setup test facts
2 set_fact:
3 cert_pw: "{{ 'password123!' + lookup('password', '/dev/null chars=ascii_letters,digits length=8') }}"
4
5 - name: setup WDAC certificates
6 wdac_setup:
7 cert_pw: '{{ cert_pw }}'
8 remote_tmp_dir: '{{ remote_tmp_dir }}'
9 register: cert_info
10 become: true
11 become_method: runas
12 vars:
13 ansible_become_user: '{{ ansible_user }}'
14 ansible_become_pass: '{{ ansible_password | default(ansible_test_connection_password) }}'
15 # WDAC cmdlets only work on WinPS.
16 ansible_pwsh_interpreter: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
17
18 - name: fetch signing certificates
19 fetch:
20 src: '{{ remote_tmp_dir }}\{{ item }}.pfx'
21 dest: '{{ local_tmp_dir }}/wdac-{{ item }}.pfx'
22 flat: yes
23 loop:
24 - signing
25 - untrusted
26
27 - name: install OpenAuthenticode
28 shell: |
29 if (-not (Get-Module -Name OpenAuthenticode -ListAvailable | Where-Object Version -ge '0.5.0')) {
30 $url = 'https://ci-files.testing.ansible.com/test/integration/targets/win_app_control/openauthenticode.0.6.1.nupkg'
31 Invoke-WebRequest -Uri $url -OutFile '{{ local_tmp_dir }}/openauthenticode.0.6.1.nupkg'
32
33 Register-PSResourceRepository -Name AnsibleTemp -Trusted -Uri '{{ local_tmp_dir }}'
34 try {
35 Install-PSResource -Name OpenAuthenticode -Repository AnsibleTemp
36 } finally {
37 Unregister-PSResourceRepository -Name AnsibleTemp
38 }
39
40 $true
41 } else {
42 $false
43 }
44 args:
45 executable: pwsh
46 register: open_auth_install
47 changed_when: open_auth_install.stdout | bool
48 notify: remove openauthenticode
49 delegate_to: localhost
50
51 - name: sign Ansible content
52 script: >-
53 New-AnsiblePowerShellSignature.ps1
54 -CollectionPath {{ local_tmp_dir ~ "/ansible_collections/ns/col" | quote }}
55 -CertPath {{ local_tmp_dir ~ "/wdac-signing.pfx" | quote }}
56 -UntrustedCertPath {{ local_tmp_dir ~ "/wdac-untrusted.pfx" | quote }}
57 -CertPass {{ cert_pw | quote }}
58 -Verbose
59 environment:
60 NO_COLOR: '1'
61 delegate_to: localhost