Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
Package: Allow one to specify version to install
Browse files Browse the repository at this point in the history
fixes: #7841
  • Loading branch information
Spredzy committed Dec 15, 2020
1 parent e3109d3 commit 6804359
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGES/7841.misc
@@ -0,0 +1,2 @@
Honor the version specified for pulpcore and plugins installation when one is using OS provided
packages.
9 changes: 9 additions & 0 deletions roles/pulp_common/README.md
Expand Up @@ -123,6 +123,7 @@ If it is set to "packages", the following variables are used, or behave *differe
* `pkg_name`: If this is left undefined, each Linux distro package will be installed by the name `pulp_pkg_name_prefix`
with the Dictionary Key appended to it. `pulp_pkg_name_prefix` defaults to "python3-", so if the Dictionary key is
"pulp-file", the package `python3-pulp-file` will be installed. This variable overrides the entire package name.
* `version`: Like with pip, a user can specify a specific version of a package one wants installed.
* **Example**:
```yaml
pulp_install_source: packages
Expand All @@ -132,6 +133,7 @@ If it is set to "packages", the following variables are used, or behave *differe
pkg_name: python3-pulp-one-ng
pulp-two:
pkg_name: pulp_two_underscores
version: 2.2.0
```
* `pulp_install_dir`: Location of the filesystem prefix where package installed python programs
(gunicorn & rq) are looked for on the filesystem. Defaults to "/usr" (such as for "/usr/bin/gunicorn").
Expand All @@ -152,6 +154,13 @@ If it is set to "packages", the following variables are used, or behave *differe
installer will fix it.)
Defaults to `false`.

Role Variables for advanced usage
---------------------------------

* `pulpcore_version`: Specify a specific version of pulpcore one would like to install or upgrade to.
By default the installer will do the right thing by using the version of pulpcore it is designed
for and tested with. It is strongly advised against setting.

Shared Variables
----------------

Expand Down
5 changes: 0 additions & 5 deletions roles/pulp_common/defaults/main.yml
Expand Up @@ -11,11 +11,6 @@ __pulp_daemons_dir: '{{ (pulp_install_source == "packages") | ternary("/usr/libe
pulp_install_api_service: true
# Deprecated unused. Variables for dependency upgrades are TBD
pulp_upgrade: false
# Intentionally not advertised to users. They should not set this unless
# they are confident that this version of pulp_installer is compatible with
# pulp_version.
# Ignored if pulp_source_dir is set
pulp_version: "3.9.0"
pulp_user: pulp
pulp_user_id:
pulp_group: pulp
Expand Down
18 changes: 15 additions & 3 deletions roles/pulp_common/tasks/install_packages.yml
Expand Up @@ -41,15 +41,23 @@

- name: "Install pulpcore via {{ ansible_facts.pkg_mgr }} packages"
package:
name: "{{ pulp_pkg_pulpcore_name }}"
name: >-
{{ pulp_pkg_pulpcore_name }}
{% if pulpcore_version | default('') | length -%}
= {{ pulpcore_version }}
{%- endif -%}
state: "{{ pulp_pkg_upgrade_all | ternary('latest','present') }}"
notify:
- Collect static content
- Restart all Pulp services

- name: "Install Pulp plugins via {{ ansible_facts.pkg_mgr }} packages"
package:
name: '{{ pulp_pkg_name_prefix }}{{ __pulp_common_package.key }}'
name: >-
{{ pulp_pkg_name_prefix }}{{ __pulp_common_package.key }}
{% if __pulp_common_package.value.version | default('') | length -%}
= {{ __pulp_common_package.value.version }}
{%- endif -%}
state: "{{ pulp_pkg_upgrade_all | ternary('latest','present') }}"
# We use pulp_install_plugins rather than pulp_install_plugins_normalized
# so that users can specify package names with underscores if distros
Expand All @@ -65,7 +73,11 @@

- name: "Install Pulp plugins (with overriden names) via {{ ansible_facts.pkg_mgr }}"
package:
name: '{{ __pulp_common_package.value.pkg_name }}'
name: >-
{{ __pulp_common_package.value.pkg_name }}
{% if __pulp_common_package.value.version | default('') | length -%}
= {{ __pulp_common_package.value.version }}
{%- endif -%}
state: "{{ pulp_pkg_upgrade_all | ternary('latest','present') }}"
loop: '{{ pulp_install_plugins | dict2items }}'
loop_control:
Expand Down
2 changes: 1 addition & 1 deletion roles/pulp_common/tasks/install_pip.yml
Expand Up @@ -212,7 +212,7 @@
# "version is incompatible with state=latest"
# But we still need to handle upgrading dependencies.
# state: "{{ pulp_upgrade | ternary('latest','present') }}"
version: '{{ pulp_version }}'
version: '{{ __pulp_version }}'
virtualenv: '{{ pulp_install_dir }}'
virtualenv_command: '{{ pulp_python_interpreter }} -m venv'
when: pulp_source_dir is undefined
Expand Down
2 changes: 1 addition & 1 deletion roles/pulp_common/templates/requirements.in.j2
@@ -1,4 +1,4 @@
pulpcore=={{ pulp_version }}
pulpcore=={{ __pulp_version }}
{% for plugin, value in pulp_install_plugins_normalized.items() %}
{% if value['source_dir'] is defined -%}
-e {{ value['source_dir'] }}
Expand Down
2 changes: 2 additions & 0 deletions roles/pulp_common/vars/main.yml
Expand Up @@ -42,5 +42,7 @@ __pulp_common_pulp_settings_fips_defaults:
- sha512
__pulp_common_merged_pulp_settings: "{{ __pulp_common_pulp_settings_defaults | combine(ansible_fips | ternary(__pulp_common_pulp_settings_fips_defaults, {}), pulp_settings, recursive=True) }}"

__pulp_version: '{{ pulpcore_version | default("3.9.0") }}'

# Pulps own replacement for django-admin setup in the proper environment
pulp_django_admin_path: "{{ pulp_install_dir }}/bin/pulpcore-manager"

0 comments on commit 6804359

Please sign in to comment.