在 Ubuntu/Debian 上安装 Visual Studio Code 的 Ansible playbook
这将从官方网站安装最新版本的 VS Code。
如果 VS Code 已安装,它将什么都不做。
vscode_install_playbook.yaml
- 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使用方式:
run_vscode_playbook.sh
ansible-playbook -i vscode.yamlIf this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow