diff --git a/README.md b/README.md index 68e82e2..71793e4 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,11 @@ Microsoft Repository An Ansible role that adds the [Microsoft repository](https://packages.microsoft.com) to Linux distributions and installs packages from it. +Upgrade to 2.x +-------------- + +Since version 2.0.0, the variable `microsoft_repository_dirs_list` has changed to `microsoft_repository_enable_prod_repository` and `microsoft_repository_additional_directories`. + Requirements ------------ @@ -56,8 +61,8 @@ Add the `Microsoft Prod` repository and install `dotnet-sdk-3.1` and `powershell roles: - role: antmelekhin.microsoft_repository microsoft_repository_packages: - - dotnet-sdk-3.1 - - powershell + - 'dotnet-sdk-3.1' + - 'powershell' ``` Add the `Microsoft Azure CLI` repository and install the azure-cli package: @@ -69,11 +74,10 @@ Add the `Microsoft Azure CLI` repository and install the azure-cli package: roles: - role: antmelekhin.microsoft_repository - microsoft_repository_dirs_list: - - name: azure-cli - type: alternative + microsoft_repository_additional_directories: + - 'azure-cli' microsoft_repository_packages: - - azure-cli + - 'azure-cli' ``` License diff --git a/defaults/main.yml b/defaults/main.yml index 2f6a2d2..81dfc1f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,8 +1,6 @@ --- microsoft_repository_mirror_url: 'https://packages.microsoft.com' microsoft_repository_gpgkey_url: '{{ microsoft_repository_mirror_url }}/keys/microsoft.asc' - -microsoft_repository_dirs_list: - - name: 'prod' - +microsoft_repository_enable_prod_repository: true +microsoft_repository_additional_directories: [] microsoft_repository_packages: [] diff --git a/meta/argument_specs.yml b/meta/argument_specs.yml index deeeb23..cf16de1 100644 --- a/meta/argument_specs.yml +++ b/meta/argument_specs.yml @@ -17,9 +17,13 @@ argument_specs: - 'Specify where to fetch the Microsoft repository GPG key file from.' - 'By default, the role uses the official Microsoft repository GPG key.' default: '{{ microsoft_repository_mirror_url }}/keys/microsoft.asc' - microsoft_repository_dirs_list: + microsoft_repository_enable_prod_repository: + type: 'bool' + description: 'Specifies whether prod repository is enabled.' + default: true + microsoft_repository_additional_directories: type: 'list' - elements: 'dict' + elements: 'str' description: 'A list of repository directories.' microsoft_repository_packages: type: 'list' diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index b72f3b7..bbdffa3 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -3,10 +3,8 @@ hosts: all roles: - role: antmelekhin.microsoft_repository - microsoft_repository_dirs_list: - - name: 'prod' - - name: 'azure-cli' - type: 'alternative' + microsoft_repository_additional_directories: + - 'azure-cli' microsoft_repository_packages: - 'powershell' - 'azure-cli' diff --git a/templates/microsoft.list.j2 b/templates/microsoft.list.j2 index dfb0fc2..ce356bd 100644 --- a/templates/microsoft.list.j2 +++ b/templates/microsoft.list.j2 @@ -1,9 +1,8 @@ {{ ansible_managed | comment }} -{% for microsoft_repository_dir in microsoft_repository_dirs_list %} -{% if microsoft_repository_dir.type is defined and microsoft_repository_dir.type == 'alternative' %} -deb [arch=amd64,arm64,armhf signed-by={{ __microsoft_repository_gpgkey_keyring }}] {{ __microsoft_repository_alternative }}/{{ microsoft_repository_dir.name }} {{ ansible_distribution_release }} main -{% else %} -deb [arch=amd64,arm64,armhf signed-by={{ __microsoft_repository_gpgkey_keyring }}] {{ __microsoft_repository_base }}/{{ microsoft_repository_dir.name }} {{ ansible_distribution_release }} main +{% if microsoft_repository_enable_prod_repository | bool %} +deb [arch=amd64,arm64,armhf signed-by={{ __microsoft_repository_gpgkey_keyring }}] {{ __microsoft_repository_prod_repository }} {% endif %} +{% for microsoft_repository_additional_directory in microsoft_repository_additional_directories %} +deb [arch=amd64,arm64,armhf signed-by={{ __microsoft_repository_gpgkey_keyring }}] {{ microsoft_repository_mirror_url }}/repos/{{ microsoft_repository_additional_directory }} {{ ansible_distribution_release }} main {% endfor %} diff --git a/templates/microsoft.repo.j2 b/templates/microsoft.repo.j2 index 87bfbc3..a0a8732 100644 --- a/templates/microsoft.repo.j2 +++ b/templates/microsoft.repo.j2 @@ -1,15 +1,20 @@ {{ ansible_managed | comment }} -{% 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 == 'alternative' %} -baseurl = {{ __microsoft_repository_alternative }}/{{ microsoft_repository_dir.name }} -{% else %} -baseurl = {{ __microsoft_repository_base }}/{{ microsoft_repository_dir.name }} +{% if microsoft_repository_enable_prod_repository | bool %} +[packages-microsoft-com-prod] +name = packages-microsoft-com-prod +baseurl = {{ __microsoft_repository_prod_repository }} +enabled = 1 +gpgcheck = 1 +gpgkey = {{ microsoft_repository_gpgkey_url }} {% endif %} + +{% for microsoft_repository_additional_directory in microsoft_repository_additional_directories %} +[{{ microsoft_repository_additional_directory }}] +name = {{ microsoft_repository_additional_directory }} +baseurl = {{ microsoft_repository_mirror_url }}/yumrepos/{{ microsoft_repository_additional_directory }} enabled = 1 gpgcheck = 1 gpgkey = {{ microsoft_repository_gpgkey_url }} -name = packages-microsoft-com-{{ microsoft_repository_dir.name }} {% endfor %} diff --git a/vars/main.yml b/vars/main.yml index b8f514e..f488449 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,14 +1,8 @@ --- __microsoft_repository_gpgkey_keyring: '/usr/share/keyrings/microsoft-archive-keyring.gpg' -__microsoft_repository_base_dict: - Debian: "{{ microsoft_repository_mirror_url }}/{{ ansible_distribution | lower }}/{{ (ansible_distribution == 'Ubuntu') | ternary(ansible_distribution_version, ansible_distribution_major_version) }}" - RedHat: '{{ microsoft_repository_mirror_url }}/rhel/{{ ansible_distribution_major_version }}' +__microsoft_repository_prod_repository_dict: + Debian: "{{ microsoft_repository_mirror_url }}/{{ ansible_distribution | lower }}/{{ (ansible_distribution == 'Ubuntu') | ternary(ansible_distribution_version, ansible_distribution_major_version) }}/prod {{ ansible_distribution_release }} main" + RedHat: '{{ microsoft_repository_mirror_url }}/rhel/{{ ansible_distribution_major_version }}/prod' -__microsoft_repository_base: '{{ __microsoft_repository_base_dict[ansible_os_family] }}' - -__microsoft_repository_alternative_dict: - Debian: '{{ microsoft_repository_mirror_url }}/repos' - RedHat: '{{ microsoft_repository_mirror_url }}/yumrepos' - -__microsoft_repository_alternative: '{{ __microsoft_repository_alternative_dict[ansible_os_family] }}' +__microsoft_repository_prod_repository: '{{ __microsoft_repository_prod_repository_dict[ansible_os_family] }}'