Skip to content

Commit

Permalink
Added Mirror support (#173)
Browse files Browse the repository at this point in the history
If you want to use a mirror server, then with this you can override the server protocol and URL, e.g. on the command line by using ansible extra-vars.
Adding leading directories is possible if needed, but no trailing slash should be used.

The default-key for this feature has that form:
```yaml
visual_studio_code_mirror: "https://packages.microsoft.com"
```
  • Loading branch information
freemanjp authored Feb 23, 2020
1 parent 1af0cf4 commit 31e75cf
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 9 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ visual_studio_code_version: ''
# Ubuntu only (code-insiders isn't in Microsoft's RPM repo)
visual_studio_code_build: stable

# Mirror server for fetching the public keys and the Visual Studio Code
# installation package. The URL may include directories. The URL must not end
# with a trailing slash.
visual_studio_code_mirror: 'https://packages.microsoft.com'

# Users to install extensions for and/or write settings.json
users: []
```
Expand Down
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@ visual_studio_code_build: stable
# Directory to store files downloaded for Visual Studio Code installation
visual_studio_code_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"

# Mirror server for fetching the public keys and the Visual Studio Code
# installation package. The URL may include directories. The URL must not end
# with a trailing slash.
visual_studio_code_mirror: 'https://packages.microsoft.com'

# Users to install extensions for and/or write settings.json
users: []
4 changes: 2 additions & 2 deletions tasks/install-apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
- name: install key (apt)
become: yes
apt_key:
url: 'https://packages.microsoft.com/keys/microsoft.asc'
url: '{{ visual_studio_code_mirror }}/keys/microsoft.asc'
state: present

- name: install VS Code repo (apt)
become: yes
apt_repository:
repo: deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main
repo: 'deb [arch=amd64] {{ visual_studio_code_mirror }}/repos/vscode stable main'
filename: vscode
state: present

Expand Down
4 changes: 2 additions & 2 deletions tasks/install-dnf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
name: code
description: Visual Studio Code repo
file: vscode
baseurl: https://packages.microsoft.com/yumrepos/vscode
gpgkey: https://packages.microsoft.com/keys/microsoft.asc
baseurl: '{{ visual_studio_code_mirror }}/yumrepos/vscode'
gpgkey: '{{ visual_studio_code_mirror }}/keys/microsoft.asc'
gpgcheck: yes

- name: install VS Code (dnf)
Expand Down
4 changes: 2 additions & 2 deletions tasks/install-yum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
name: code
description: Visual Studio Code repo
file: vscode
baseurl: https://packages.microsoft.com/yumrepos/vscode
gpgkey: https://packages.microsoft.com/keys/microsoft.asc
baseurl: '{{ visual_studio_code_mirror }}/yumrepos/vscode'
gpgkey: '{{ visual_studio_code_mirror }}/keys/microsoft.asc'
gpgcheck: yes

- name: install VS Code (yum)
Expand Down
2 changes: 1 addition & 1 deletion tasks/install-zypper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
become: yes
rpm_key:
state: present
key: https://packages.microsoft.com/keys/microsoft.asc
key: '{{ visual_studio_code_mirror }}/keys/microsoft.asc'

- name: write repo configuration (zypper)
become: yes
Expand Down
4 changes: 2 additions & 2 deletions templates/vscode.repo.j2
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{ ansible_managed | comment }}
[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
baseurl={{ visual_studio_code_mirror }}/yumrepos/vscode
enabled=1
type=rpm-md
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
gpgkey={{ visual_studio_code_mirror }}/keys/microsoft.asc

0 comments on commit 31e75cf

Please sign in to comment.