Skip to content

Commit f8e2919

Browse files
committed
Uses deb822 repository module to avoid boiler plate code
1 parent 8278310 commit f8e2919

File tree

1 file changed

+10
-46
lines changed

1 file changed

+10
-46
lines changed

tasks/install-apt.yml

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,6 @@
1515
path: '/etc/apt/keyrings/microsoft.asc'
1616
state: absent
1717

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-
5418
- name: Remove old repo (apt)
5519
become: true
5620
ansible.builtin.file:
@@ -60,20 +24,20 @@
6024

6125
- name: Install VS Code repo (apt)
6226
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 }}"
7336
when: not visual_studio_code_skip_add_repo
7437

7538
- name: Install VS Code (apt)
7639
become: true
7740
ansible.builtin.apt:
7841
name: "{{ visual_studio_code_package }}{{ (visual_studio_code_version | length > 0) | ternary('=' + visual_studio_code_version, '') }}"
7942
state: present
43+
update_cache: true

0 commit comments

Comments
 (0)