Ansible playbook to install Visual Studio code on Ubuntu/Debian
This will install the most recent version of VS code from the official website.
If VS code is already installed, it will do nothing at all.
- name: Install Visual Studio Code
hosts: all
become: true
tasks:
- name: Check if VS Code is installed
command: dpkg-query -W code
register: is_installed
failed_when: false
changed_when: false
- name: Download VS Code deb package
get_url:
url: https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64
dest: /tmp/vscode.deb
when: is_installed.rc != 0
- name: Install VS Code package
apt:
deb: /tmp/vscode.deb
state: present
when: is_installed.rc != 0
- name: Clean up downloaded deb
file:
path: /tmp/vscode.deb
state: absent
when: is_installed.rc != 0
Use like this:
ansible-playbook -i vscode.yaml
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow