Manage native VS Code on Fedora GNOME

This commit is contained in:
2026-11-04 23:11:24 +01:00
parent 667f55b87b
commit ada83e97d3
3 changed files with 68 additions and 0 deletions

View File

@@ -121,3 +121,7 @@ thunderbird_icloud_caldav_url: https://caldav.icloud.com/
thunderbird_icloud_carddav_url: https://contacts.icloud.com/ thunderbird_icloud_carddav_url: https://contacts.icloud.com/
thunderbird_icloud_calendar_id: 4f2c1d6e-9b3a-4f7c-8e21-6d5a0c9b7e13 thunderbird_icloud_calendar_id: 4f2c1d6e-9b3a-4f7c-8e21-6d5a0c9b7e13
thunderbird_icloud_addressbook_uid: 9e0b7c4a-2d51-4a8f-b6c3-1f7d5e2a8b46 thunderbird_icloud_addressbook_uid: 9e0b7c4a-2d51-4a8f-b6c3-1f7d5e2a8b46
# Native VS Code; opt in to managing settings only after defining them.
vscode_extensions: []
vscode_settings: null

View File

@@ -284,3 +284,7 @@
tags: [dotfiles, dotfiles:desktop, gnome, thunderbird] tags: [dotfiles, dotfiles:desktop, gnome, thunderbird]
ansible.builtin.import_tasks: thunderbird.yml ansible.builtin.import_tasks: thunderbird.yml
when: thunderbird_icloud_enabled | default(false) | bool when: thunderbird_icloud_enabled | default(false) | bool
- name: Configure native VS Code
tags: [vscode]
ansible.builtin.import_tasks: vscode.yml

View File

@@ -0,0 +1,60 @@
---
- name: Configure Microsoft VS Code repository
ansible.builtin.yum_repository:
name: code
description: Visual Studio Code
baseurl: https://packages.microsoft.com/yumrepos/vscode
enabled: true
gpgcheck: true
gpgkey: https://packages.microsoft.com/keys/microsoft.asc
- name: Install native VS Code
ansible.builtin.dnf:
name: code
state: present
- name: List installed VS Code extensions
ansible.builtin.command:
argv: [code, --list-extensions]
become: true
become_user: "{{ username }}"
environment:
HOME: "{{ user_home }}"
register: vscode_installed_extensions
changed_when: false
check_mode: false
when:
- vscode_extensions | length > 0
- not ansible_check_mode
- name: Install missing VS Code extensions
ansible.builtin.command:
argv: [code, --install-extension, "{{ item }}"]
become: true
become_user: "{{ username }}"
environment:
HOME: "{{ user_home }}"
loop: "{{ vscode_extensions }}"
when:
- not ansible_check_mode
- item | lower not in (vscode_installed_extensions.stdout_lines | default([]) | map('lower') | list)
changed_when: true
- name: Ensure VS Code user configuration directory exists
ansible.builtin.file:
path: "{{ user_home }}/.config/Code/User"
state: directory
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "0755"
when: vscode_settings is not none
- name: Deploy explicitly managed VS Code settings
ansible.builtin.copy:
dest: "{{ user_home }}/.config/Code/User/settings.json"
content: "{{ vscode_settings | to_nice_json }}\n"
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "0644"
backup: true
when: vscode_settings is not none