Skip to content

Commit b407224

Browse files
authored
Merge pull request #14 from Zuehlke/feature/install-vscode
Install VScode and zbr.vscode-ansible plugin
2 parents 332f334 + 0c6d3b6 commit b407224

5 files changed

Lines changed: 60 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ For the Chef-based equivalent of it, see https://github.com/Zuehlke/linux-develo
1919

2020
These are the main tools included in this developer VM:
2121

22-
* ...(add your tools here)
22+
* [VSCode](https://code.visualstudio.com/) - as a general purpose (code) editor
2323

2424
Apart from the above, the following tools are used to set up and maintain this developer VM:
2525

@@ -32,6 +32,8 @@ Apart from the above, the following tools are used to set up and maintain this d
3232
Other tweaks and settings worth mentioning:
3333

3434
* places a `README.md` file on the Desktop to guide first time users after they logged in to the VM
35+
* sets up `~/.bashrc.d` directory to ease management of bash initialization (e.g. for setting env vars)
36+
* adds a Git `PS1` shell prompt and configures some useful aliases and settings in `~/.gitconfig`
3537
* symlinks [`update-vm.sh`](scripts/update-vm.sh) to `/usr/local/bin/update-vm` so it's in the `$PATH` and can be used for updating the VM from the inside (see below)
3638

3739

roles/vscode/tasks/main.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
3+
- name: Add VSCode apt signing key if not present
4+
apt_key:
5+
id: BC528686B50D79E339D3721CEB3E94ADBE1229CF
6+
url: https://packages.microsoft.com/keys/microsoft.asc
7+
state: present
8+
9+
- name: Add Microsoft's VSCode repository into sources list
10+
apt_repository:
11+
repo: deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main
12+
state: present
13+
14+
- name: Install VSCode
15+
apt:
16+
name: code
17+
state: present
18+
19+
- name: List VSCode Extensions
20+
command:
21+
cmd: code --list-extensions
22+
register: vscode_installed_extensions
23+
changed_when: false
24+
become: yes
25+
become_user: "{{ ansible_env.SUDO_USER }}"
26+
27+
- name: Install VSCode Extensions
28+
command:
29+
cmd: code --install-extension "{{ item }}"
30+
with_items: "{{ vscode_extensions }}"
31+
when: not vscode_installed_extensions is search(item)
32+
become: yes
33+
become_user: "{{ ansible_env.SUDO_USER }}"

roles/vscode/vars/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
vscode_extensions:
3+
- zbr.vscode-ansible

site.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
- { role: testinfra, tags: "testinfra" }
1515
- { role: bashrc_d, tags: "bashrc_d" }
1616
- { role: git, tags: "git" }
17+
- { role: vscode, tags: "vscode" }

spec/test_vscode.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import pytest
2+
3+
def test_vscode_apt_sources_list_exists_(host):
4+
assert host.file('/etc/apt/sources.list.d/packages_microsoft_com_repos_vscode.list').exists
5+
6+
def test_vscode_apt_key_defined_(host):
7+
assert 'Microsoft (Release signing) <gpgsecurity@microsoft.com>' in host.run('apt-key list').stdout
8+
9+
def test_vscode_command_is_found_(host):
10+
assert host.run('which code').rc is 0
11+
12+
def test_vscode_version_command_succeeds_(host):
13+
assert host.run('code --version').rc is 0
14+
15+
@pytest.mark.parametrize('extension', [
16+
'zbr.vscode-ansible'
17+
])
18+
def test_vscode_extensions_include_defined_extensions_(host, extension):
19+
installed_extensions = host.run('code --list-extensions').stdout
20+
assert extension in installed_extensions

0 commit comments

Comments
 (0)