An Ansible role that installs Visual Studio Code on Red Hat-based Linux distributions (RHEL, CentOS, Fedora, Rocky Linux, AlmaLinux).
This role automates the installation of Microsoft Visual Studio Code by:
- Adding Microsoft's official repository and GPG key
- Installing the latest version of VS Code from the official repository
- Ensuring the system package cache is updated
- Ansible 2.1 or higher
- Target systems running Red Hat-based distributions (RHEL, CentOS, Fedora, Rocky Linux, AlmaLinux)
- Internet connectivity to download packages from Microsoft's repository
dnfpackage manager (standard on modern Red Hat-based systems)
This role currently uses no configurable variables. It installs the latest available version of VS Code from Microsoft's official repository.
None.
---
- hosts: workstations
become: yes
roles:
- vs_code---
- hosts: developers
become: yes
roles:
- vs_code
- hosts: testing_machines
become: yes
roles:
- vs_code---
- hosts: dev_workstations
become: yes
roles:
- git_config
- nodejs
- vs_code
- docker- Imports Microsoft GPG Key: Adds Microsoft's official GPG key for package verification
- Sets Up Repository: Installs the VS Code repository configuration file
- Installs VS Code: Uses dnf to install the latest version of Visual Studio Code
- Updates Package Cache: Ensures the latest package information is available
/etc/yum.repos.d/vscode.repo- Repository configuration file for VS Code updates
The role configures the official Microsoft Visual Studio Code repository:
[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.ascAfter the role completes:
- VS Code will be available in the system PATH as
code - Users can launch VS Code from the command line or application menu
- Future updates will be available through the system package manager (
dnf update)
Supported Distributions:
- Red Hat Enterprise Linux 8+
- CentOS 8+
- Rocky Linux 8+
- AlmaLinux 8+
- Fedora 32+
Package Manager:
- Uses
dnf(modern replacement foryum)
Test the role using the included test playbook:
cd tests/
ansible-playbook -i inventory test.yml- Root Privileges Required: This role requires
become: yesas it installs system packages - Internet Access: Target machines need internet connectivity to download from Microsoft's repository
- Automatic Updates: Once installed, VS Code will receive updates through normal system updates
- GPG Verification: All packages are cryptographically verified using Microsoft's GPG key
- Developer Workstation Setup: Automated provisioning of development environments
- Lab Environment Configuration: Setting up consistent coding environments for training
- CI/CD Agent Preparation: Installing VS Code on build agents for testing purposes
- Classroom/Workshop Setup: Rapid deployment across multiple student machines
- Uses official Microsoft repository (not third-party sources)
- GPG signature verification ensures package integrity
- Always installs the latest version with security updates
BSD
Role for automated Visual Studio Code installation on Red Hat-based Linux systems.