Skip to content

Commit

Permalink
improv: update variable names and add other changes (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
antmelekhin committed Mar 10, 2024
1 parent ea64756 commit 21cad76
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Requirements
Role Variables
--------------

- `microsoft_repository_mirror` Mirror of `Microsoft` repository (default: `https://packages.microsoft.com`).
- `microsoft_repository_key_url` URL to `Microsoft's` GPG public key file (default: `https://packages.microsoft.com/keys/microsoft.asc`).
- `microsoft_repository_mirror_url` Mirror of `Microsoft` repository (default: `https://packages.microsoft.com`).
- `microsoft_repository_gpgkey` URL to `Microsoft's` GPG public key file (default: `https://packages.microsoft.com/keys/microsoft.asc`).
- `microsoft_repository_dirs_list` List of repository directories. See [repository structure](https://packages.microsoft.com/).

Available values:
Expand Down Expand Up @@ -75,7 +75,7 @@ Example Playbook
- role: antmelekhin.microsoft_repository
microsoft_repository_dirs_list:
- name: azure-cli
type: alternate
type: alternative
microsoft_repository_packages:
- azure-cli
```
Expand Down
4 changes: 2 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
microsoft_repository_mirror: 'https://packages.microsoft.com'
microsoft_repository_key_url: 'https://packages.microsoft.com/keys/microsoft.asc'
microsoft_repository_mirror_url: 'https://packages.microsoft.com'
microsoft_repository_gpgkey: '{{ microsoft_repository_mirror_url }}/keys/microsoft.asc'

microsoft_repository_dirs_list:
- name: prod
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
microsoft_repository_dirs_list:
- name: prod
- name: azure-cli
type: alternate
type: alternative
microsoft_repository_packages:
- powershell
- azure-cli
3 changes: 2 additions & 1 deletion tasks/install-Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

- name: 'Add Microsoft APT key'
ansible.builtin.apt_key:
url: '{{ microsoft_repository_key_url }}'
url: '{{ microsoft_repository_gpgkey }}'
keyring: '/usr/share/keyrings/microsoft-archive-keyring.gpg'
state: present
when: not ansible_check_mode

Expand Down
5 changes: 0 additions & 5 deletions tasks/install-RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
- name: 'Configure DNF/YUM repository and install Microsoft packages'
become: true
block:
- name: 'Add Microsoft DNF/YUM key'
ansible.builtin.rpm_key:
key: '{{ microsoft_repository_key_url }}'
state: present

- name: 'Add Microsoft DNF/YUM repository'
ansible.builtin.template:
src: 'microsoft.repo.j2'
Expand Down
6 changes: 3 additions & 3 deletions templates/microsoft.list.j2
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{ ansible_managed | comment }}

{% for microsoft_repository_dir in microsoft_repository_dirs_list %}
{% if microsoft_repository_dir.type is defined and microsoft_repository_dir.type == 'alternate' %}
deb [arch=amd64,arm64,armhf] {{ microsoft_repository_mirror }}/repos/{{ microsoft_repository_dir.name }} {{ ansible_distribution_release }} main
{% if microsoft_repository_dir.type is defined and microsoft_repository_dir.type == 'alternative' %}
deb [arch=amd64,arm64,armhf signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] {{ _microsoft_repository_alternative_mirror_url }}/{{ microsoft_repository_dir.name }} {{ ansible_distribution_release }} main
{% else %}
deb [arch=amd64,arm64,armhf] {{ _microsoft_repository_baseurl }}/{{ microsoft_repository_dir.name }} {{ ansible_distribution_release }} main
deb [arch=amd64,arm64,armhf signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] {{ _microsoft_repository_base_mirror_url }}/{{ microsoft_repository_dir.name }} {{ ansible_distribution_release }} main
{% endif %}
{% endfor %}
8 changes: 4 additions & 4 deletions templates/microsoft.repo.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

{% for microsoft_repository_dir in microsoft_repository_dirs_list %}
[packages-microsoft-com-{{ microsoft_repository_dir.name }}]
{% if microsoft_repository_dir.type is defined and microsoft_repository_dir.type == 'alternate' %}
baseurl = {{ microsoft_repository_mirror }}/yumrepos/{{ microsoft_repository_dir.name }}
{% if microsoft_repository_dir.type is defined and microsoft_repository_dir.type == 'alternative' %}
baseurl = {{ _microsoft_repository_alternative_mirror_url }}/{{ microsoft_repository_dir.name }}
{% else %}
baseurl = {{ _microsoft_repository_baseurl }}/{{ microsoft_repository_dir.name }}
baseurl = {{ _microsoft_repository_base_mirror_url }}/{{ microsoft_repository_dir.name }}
{% endif %}
enabled = 1
gpgcheck = 1
gpgkey = {{ microsoft_repository_key_url }}
gpgkey = {{ microsoft_repository_gpgkey }}
name = packages-microsoft-com-{{ microsoft_repository_dir.name }}

{% endfor %}
3 changes: 2 additions & 1 deletion vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
_microsoft_repository_baseurl: '{{ microsoft_repository_mirror }}/{{ ansible_distribution | lower }}/{{ ansible_distribution_major_version }}'
_microsoft_repository_base_mirror_url: '{{ microsoft_repository_mirror_url }}/{{ ansible_distribution | lower }}/{{ ansible_distribution_major_version }}'
_microsoft_repository_alternative_mirror_url: '{{ microsoft_repository_mirror_url }}/repos'
3 changes: 2 additions & 1 deletion vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
_microsoft_repository_baseurl: '{{ microsoft_repository_mirror }}/rhel/{{ ansible_distribution_major_version }}'
_microsoft_repository_base_mirror_url: '{{ microsoft_repository_mirror_url }}/rhel/{{ ansible_distribution_major_version }}'
_microsoft_repository_alternative_mirror_url: '{{ microsoft_repository_mirror_url }}/yumrepos'
3 changes: 2 additions & 1 deletion vars/Ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
_microsoft_repository_baseurl: '{{ microsoft_repository_mirror }}/{{ ansible_distribution | lower }}/{{ ansible_distribution_version }}'
_microsoft_repository_base_mirror_url: '{{ microsoft_repository_mirror_url }}/{{ ansible_distribution | lower }}/{{ ansible_distribution_version }}'
_microsoft_repository_alternative_mirror_url: '{{ microsoft_repository_mirror_url }}/repos'

0 comments on commit 21cad76

Please sign in to comment.