diff --git a/defaults/main.yml b/defaults/main.yml index 62058a3..b15b8a0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -27,6 +27,10 @@ visual_studio_code_mirror: 'https://packages.microsoft.com' # - for zypper the option gpgcheck is set to 0 visual_studio_code_gpgcheck: true +# Indicates if apt should use deb822 or one-line sources format +# See https://repolib.readthedocs.io/en/latest/deb822-format.html +visual_studio_code_use_deb822_format: false + # skip task to add repo for remote package manager # if set to true, the task 'install VS Code repo (apt/yum/dnf/zypper)' will be skipped # if set to false, the repo will be added, this is the default diff --git a/tasks/apt-source-deb822.yml b/tasks/apt-source-deb822.yml new file mode 100644 index 0000000..4ab3030 --- /dev/null +++ b/tasks/apt-source-deb822.yml @@ -0,0 +1,14 @@ +# code: language=ansible +--- +- name: Install VS Code repo (apt - deb822) + become: true + ansible.builtin.deb822_repository: + name: vscode + types: deb + uris: "{{ visual_studio_code_mirror }}/repos/code" + suites: stable + components: main + architectures: "{{ visual_studio_code_deb_architecture }}" + signed_by: "{{ visual_studio_code_mirror }}/keys/microsoft.asc" + trusted: "{{ not visual_studio_code_gpgcheck }}" + when: not visual_studio_code_skip_add_repo diff --git a/tasks/apt-source-oneline.yml b/tasks/apt-source-oneline.yml new file mode 100644 index 0000000..012c5f3 --- /dev/null +++ b/tasks/apt-source-oneline.yml @@ -0,0 +1,29 @@ +# code: language=ansible +--- +- name: Install dependencies (apt - oneline) + become: true + ansible.builtin.apt: + name: + - ca-certificates + - apt-transport-https + state: present + +- name: Install key (apt - oneline) + become: true + ansible.builtin.get_url: + url: '{{ visual_studio_code_mirror }}/keys/microsoft.asc' + dest: '/etc/apt/keyrings/' + mode: 'u=rw,go=r' + force: true + +- name: Install VS Code repo (apt - oneline) + become: true + ansible.builtin.apt_repository: + repo: >- + deb [arch={{ visual_studio_code_deb_architecture }} + {{ visual_studio_code_gpgcheck | ternary("", " trusted=true") }} + signed-by=/etc/apt/keyrings/microsoft.asc] + {{ visual_studio_code_mirror }}/repos/code stable main + filename: vscode + state: present + when: not visual_studio_code_skip_add_repo diff --git a/tasks/install-apt.yml b/tasks/install-apt.yml index 1af5efb..b45b397 100644 --- a/tasks/install-apt.yml +++ b/tasks/install-apt.yml @@ -1,39 +1,13 @@ # code: language=ansible --- -- name: Install dependencies (apt) - become: true - ansible.builtin.apt: - name: - - ca-certificates - - apt-transport-https - state: present - -- name: Create APT keyrings dir +- name: Create keyrings dir (apt) become: true ansible.builtin.file: path: '/etc/apt/keyrings' state: directory mode: 'u=rwx,go=rx' -- name: Install key (apt) - become: true - ansible.builtin.get_url: - url: '{{ visual_studio_code_mirror }}/keys/microsoft.asc' - dest: '/etc/apt/keyrings/' - mode: 'u=rw,go=r' - force: true - -- name: Install VS Code repo (apt) - become: true - ansible.builtin.apt_repository: - repo: >- - deb [arch={{ visual_studio_code_deb_architecture }} - {{ visual_studio_code_gpgcheck | ternary("", " trusted=true") }} - signed-by=/etc/apt/keyrings/microsoft.asc] - {{ visual_studio_code_mirror }}/repos/code stable main - filename: vscode - state: present - when: not visual_studio_code_skip_add_repo +- include_tasks: 'apt-source-{{ visual_studio_code_use_deb822_format | ternary("deb822", "oneline" )}}.yml' - name: Install VS Code (apt) become: true