Debian Codegraph @

ansible_collections/community/windows/tests/integration/targets/win_psscript/tasks/setup_repos.yml

raw
1 # This file is part of Ansible
2
3 # Copyright: (c) 2020, Brian Scholer <@briantist>
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5 ---
6 - name: Unregister all repositories
7 ansible.windows.win_shell: |
8 Get-PSRepository | Unregister-PSRepository
9 notify: Add PSGallery
10
11 - name: Create repo folders
12 ansible.windows.win_file:
13 path: '{{ item.path }}'
14 state: directory
15 loop: "{{ repos }}"
16 notify: Remove Directories
17
18 - name: Register repos
19 win_psrepository:
20 name: '{{ item.name }}'
21 source: '{{ item.path }}'
22 installation_policy: '{{ item.policy }}'
23 notify: Clear Repositories
24 loop: "{{ repos }}"
25
26 - name: Create and Publish Scripts
27 ansible.windows.win_shell: |
28 $tmp = '{{ remote_tmp_dir }}'
29
30 # it looks like Tls12 is not added during the nuget bootstrapping process
31 # hitting connection closed errors during some tests. May be related to this:
32 # https://devblogs.microsoft.com/nuget/deprecating-tls-1-0-and-1-1-on-nuget-org/
33 [System.Net.ServicePointManager]::SecurityProtocol = `
34 [System.Net.ServicePointManager]::SecurityProtocol -bor
35 [System.Net.SecurityProtocolType]::SystemDefault -bor
36 [System.Net.SecurityProtocolType]::Tls11 -bor
37 [System.Net.SecurityProtocolType]::Tls12
38
39 {% for version in versions %}
40 {% for repo in repos %}
41 {% for script in repo.scripts %}
42
43 $script = '{{ script }}'
44 $repo = '{{ repo.name }}'
45 $ver = '{{ version }}'
46 $file = "${script}.ps1"
47 $out = $tmp | Join-Path -ChildPath $file
48
49 try {
50 New-ScriptFileInfo -Description $script -Version $ver -Path $out -Force
51 Publish-Script -Path $out -Repository $repo -Force
52 } finally {
53 Remove-Item -LiteralPath $out -Force -ErrorAction SilentlyContinue
54 }
55
56 {% endfor %}
57 {% endfor %}
58 {% endfor %}