Skip to content

Instantly share code, notes, and snippets.

@M0r13n
Created October 22, 2022 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save M0r13n/a49268c7931d8becb74b7c4e0f7b9767 to your computer and use it in GitHub Desktop.
Save M0r13n/a49268c7931d8becb74b7c4e0f7b9767 to your computer and use it in GitHub Desktop.
Ansible playbook to download & install VS Code Server on a remote machine (without internet connection / offline)

Ansible playbook to download & install VS Code Server on a remote machine (without internet connection / offline)

By default VS Code installs its server component on a remote server automatically when using the SSH extension. This does not work when working in an air gapped environment or when working offline.

This playbook downloads the VS Code Server on a remote machine. It also extracts the tarball to the correct location. After running this playbook you can connect to the remote machine using the VS Code SSH extension.

How to run

  • you might need to adjust vscode_commit_sha to your commit SHA
    • you can get the correct commit SHA by openeing help > About > Commit
  • you might need to vscode_arch to the architecture of the remote machine
    • e.g. x64 or arm64

You can run the playbook as follows:

`ansible-playbook install_code.yml -i localhost,

(replace localhost with your desired remote machine)

Note

You'll still need to install any extensions manually. This can be done by downloading .vsix files and installing them manually on the remote machine.

---
- hosts: all
vars:
vscode_commit_sha: "129500ee4c8ab7263461ffe327268ba56b9f210d"
vscode_download_base_url: "https://update.code.visualstudio.com"
vscode_arch: "arm64" # x64
vscode_install_file: "server-linux-{{ vscode_arch }}"
vscode_full_download_url: "{{ vscode_download_base_url }}/commit:{{ vscode_commit_sha }}/{{ vscode_install_file }}/stable"
tasks:
- name: Delete previous installation if it exists
ansible.builtin.file:
path: "~/.vscode-server/bin/{{ vscode_commit_sha }}"
state: absent
mode: '0644'
- name: Download VS Code Server
ansible.builtin.get_url:
url: "{{ vscode_full_download_url }}"
dest: /tmp/vscode-server-linux.tar.gz
mode: '0644'
- name: Create the parent directory for vscode server
ansible.builtin.file:
path: "~/.vscode-server/bin/{{ vscode_commit_sha }}"
state: directory
mode: '0755' # TODO verify
- name: Unarchive a file with extra options
ansible.builtin.unarchive:
src: /tmp/vscode-server-linux.tar.gz
dest: "~/.vscode-server/bin/{{ vscode_commit_sha }}"
remote_src: true
extra_opts:
- --strip-components=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment