|
15 | 15 | path: '/etc/apt/keyrings/microsoft.asc' |
16 | 16 | state: absent |
17 | 17 |
|
18 | | -- name: Create APT keyrings dir |
19 | | - become: true |
20 | | - ansible.builtin.file: |
21 | | - path: '/usr/share/keyrings/' |
22 | | - state: directory |
23 | | - mode: 'u=rwx,go=rx' |
24 | | - |
25 | | -- name: Download key (apt) |
26 | | - become: true |
27 | | - ansible.builtin.get_url: |
28 | | - url: '{{ visual_studio_code_mirror }}/keys/microsoft.asc' |
29 | | - dest: '/tmp/' |
30 | | - mode: 'u=rw,go=r' |
31 | | - force: true |
32 | | - |
33 | | -- name: Dearmor key (apt) |
34 | | - ansible.builtin.command: gpg --dearmor -o /tmp/microsoft.gpg /tmp/microsoft.asc |
35 | | - args: |
36 | | - creates: '/tmp/microsoft.gpg' |
37 | | - |
38 | | -- name: Install key (apt) |
39 | | - become: true |
40 | | - ansible.builtin.copy: |
41 | | - src: '/tmp/microsoft.gpg' |
42 | | - dest: '/usr/share/keyrings/microsoft.gpg' |
43 | | - mode: 'u=rw,go=r' |
44 | | - force: true |
45 | | - |
46 | | -- name: Clean up temporary key files (apt) |
47 | | - ansible.builtin.file: |
48 | | - path: "{{ item }}" |
49 | | - state: absent |
50 | | - loop: |
51 | | - - /tmp/microsoft.asc |
52 | | - - /tmp/microsoft.gpg |
53 | | - |
54 | 18 | - name: Remove old repo (apt) |
55 | 19 | become: true |
56 | 20 | ansible.builtin.file: |
|
60 | 24 |
|
61 | 25 | - name: Install VS Code repo (apt) |
62 | 26 | become: true |
63 | | - ansible.builtin.copy: |
64 | | - content: | |
65 | | - Types: deb |
66 | | - URIs: {{ visual_studio_code_mirror }}/repos/code |
67 | | - Suites: stable |
68 | | - Components: main |
69 | | - Architectures: {{ visual_studio_code_deb_architecture }} |
70 | | - {{ 'Trusted: yes' if not visual_studio_code_gpgcheck else 'Signed-By: /usr/share/keyrings/microsoft.gpg' }} |
71 | | - dest: '/etc/apt/sources.list.d/vscode.sources' |
72 | | - mode: 'u=rw,go=r' |
| 27 | + ansible.builtin.deb822_repository: |
| 28 | + name: vscode |
| 29 | + types: deb |
| 30 | + uris: "{{ visual_studio_code_mirror }}/repos/code" |
| 31 | + suites: stable |
| 32 | + components: main |
| 33 | + architectures: "{{ visual_studio_code_deb_architecture }}" |
| 34 | + signed_by: "{{ visual_studio_code_mirror + '/keys/microsoft.asc' if visual_studio_code_gpgcheck else omit }}" |
| 35 | + trusted: "{{ true if not visual_studio_code_gpgcheck else omit }}" |
73 | 36 | when: not visual_studio_code_skip_add_repo |
74 | 37 |
|
75 | 38 | - name: Install VS Code (apt) |
76 | 39 | become: true |
77 | 40 | ansible.builtin.apt: |
78 | 41 | name: "{{ visual_studio_code_package }}{{ (visual_studio_code_version | length > 0) | ternary('=' + visual_studio_code_version, '') }}" |
79 | 42 | state: present |
| 43 | + update_cache: true |
0 commit comments